{"id":"raphtalia/canvas","name":"canvas","scope":"raphtalia","platform":"roblox","description":"Efficient Roblox image rendering library","version":"1.0.0","latest":"1.0.0","versions":["1.0.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"c5b9a12527c00ee6dce5dbf84f334b2e4ab74af0257161e3c7a10b42ed985fc0","likes":0,"downloads":0,"install":"forest install raphtalia/canvas","url":"https://forest.dev/p/roblox/raphtalia/canvas","files":"https://api.forest.dev/ai/package/roblox/raphtalia/canvas/files","readme":"# Canvas\r\n\r\nRenders images using UIGradients to reduce the number of frames needed.\r\nCurrently due to Roblox engine limitations there is a maximum of 128^2\r\nunique colors. Works well in conjunction with\r\n[Roblox-PNG-Library](https://github.com/CloneTrooper1019/Roblox-PNG-Library).\r\nPlease do not use this library to bypass Roblox moderation, it is purely for\r\nfun.\r\n\r\nThis example uses Roblox PNG Library to render an image imported into Studio.\r\n\r\n```lua\r\nlocal DOWNSCALING = 1\r\n\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\r\nlocal StarterGui = game:GetService(\"StarterGui\")\r\nlocal StudioService = game:GetService(\"StudioService\")\r\n\r\nlocal Canvas = require(ReplicatedStorage.Canvas)\r\nlocal PNG = require(ReplicatedStorage.PNG) -- Roblox PNG Library\r\n\r\nlocal file = StudioService:PromptImportFile({\"png\"})\r\nlocal image = PNG.new(file:GetBinaryContents())\r\nlocal canvas = Canvas.new(\r\n    image.Width / DOWNSCALING,\r\n    image.Height / DOWNSCALING\r\n)\r\n\r\nfunction canvas:GetPixel(x, y)\r\n    --[[\r\n        Overwrite the canvas's GetPixel method to use PNG instead. This saves\r\n        us time during the prerendering process so we don't have to loop\r\n        through the image to set every pixel on the canvas.\r\n    ]]\r\n    return image:GetPixel(\r\n        x * DOWNSCALING,\r\n        y * DOWNSCALING\r\n    )\r\nend\r\n\r\nlocal frame = canvas:Render()\r\nlocal screengui = Instance.new(\"ScreenGui\")\r\nframe.Parent = screengui\r\nscreengui.Parent = StarterGui\r\n```\r\n","readmeTruncated":false}