CanvasDraw - A powerful pixel-based graphics library (Draw pixels, lines, triangles, read/modify image data, and much more!)

I have been looking for this for a very long time, I was wondering how you could also “Redo” after doing “Undo”? Been trying for the past 3 hours but just couldn’t do it

Oh, thank you so much for fixing this. I’ve been trying to figure out why I haven’t been able to use ascii characters for ages.

I think one way to do this is like so:

Whenever you undo, instead of removing the latest saved frame from the table, we instead keep it and use a number value that goes up and down when ever we undo and redo, and just index the saved frame with that number to draw it

Module Patch / Small Update - v4.6.1

CanvasDraw fonts can now support multi-byte UTF-8 characters (such as greek letters, ascii characters, blocks, etc)

The Codepage and CodepageLarge fonts have been updated and now support 254 characters

These changes affect Canvas:DrawText() and Canvas:DrawTextXY()


Special thanks to @Lxi099!


CanvasDraw4.6.1.b.rbxm (63.2 KB)

4 Likes

That’l be good, especially for any games using CanvasDraw that want an easy way to incorporate Graphics Levels* for performance on different devices.

*(Not 100% even needed since CanvasDraw is so optimized!)

1 Like

CanvasDraw Tools Plugin - Image Editor Temporarily Broken

Hey all, we currently have an EditableImage rendering issue with the plugin, which causes the Image Editor to no longer show anything while drawing/importing an image.

This issue should be fixed sometime on Monday


EDIT: The issue has now been resolved

1 Like

Small Optimisation Update - v4.6.2

Hey all, this update is one of the few rare optimisation updates where I somehow make CanvasDraw even faster than it already is!


Here is the list of changes:

  • Improved performance by 20% for textured triangles. This affects the following methods:

    • Canvas:DrawTexturedTriangle() and Canvas:DrawTexturedTriangleXY()
    • Canvas:DrawDistortedImage() and Canvas:DrawDistortedImageXY()
    • Canvas:DrawRotatedImage() and Canvas:DrawRotatedImageXY()
    • Canvas:DrawImageRect() and Canvas:DrawImageRectXY()
  • Improved performance for Canvas:DrawTriangle() and Canvas:DrawTriangleXY() by 22%

  • Fixed and increased performance for Canvas:ClearPixels() and Canvas:FillPixels() by over 200%


CanvasDraw4.6.2.b.rbxm (63.6 KB)

1 Like

Optimisation Update - v4.7.0


Hey all, roblox has recently released a new API for EditableImages that allows us to use buffers efficiently with them.

CanvasDraw now uses 8-bit integer buffers instead of arrays of doubles for the pixel grid management.

Doing this has not only improved memory usage, but also has improved framerate as well!


From a 1024x1024 Canvas:SetRGB() with clearing for every heartbeat test, I have acheived the following numbers:

  • CanvasDraw v4.6.2 (Previous Version):

    • 13 FPS
  • CanvasDraw v4.7.0 (Newest Version):

    • 18 FPS

This update has also reduced ImageData size by about 33%

Prior to this update, an uncompressed 1024x1024 ImageData would take up 0.3 GB of memory, and now with this update the same image only takes up 0.1 GB of memory!


CanvasDraw4.7.0.b.rbxm (64.2 KB)

4 Likes

Yay! More Mandelbrot frames per recording! But to be fair, I’m happier with the FPS improvements! Thanks, Roblox and my beloved Ethan.

2 Likes

Hey @Ethanthegrand14, Can we also have vector font support, and be able to easily add new fonts to it. I’d like to get in touch with you through a social media if possible to discuss about certain stuff.

Regarding optimizations, I think the Colors of CanvasDraw can be also optimized similarly to OSGL if not already optimized.

1 Like

For now, vector fonts are beyond the scope of CanvasDraw, it is simply just too complicated to add in nicely and I currently do not know how i’d even go about doing it and moving away from bitmap fonts is currently not planned.

CanvasDraw’s colours are already optimised and very fast (as they are literally just barebone numbers). Proably as fast as can be at the moment, and last time I checked out OSGL, their colours are very slow as they use a lot of classes with it, which is pretty slow for per-pixel performance.

Canvas:SetRGB(X, Y, R, G, B) -- Avoids colour or Color3 construction. Perfect for per-pixel processing

If you have any other in-depth questions, I can indeed add you on discord if you have that

I agree with vector fonts being difficult to add. I currently have managed to add all Roblox fonts in vector, however, currently the biggest issue im having is that certain features are not working perfectly, and its still missing a lot of stuff so I guess I could say I’ve given up on it personally mostly due to lack of time. I also have this written in p5js editor so other developers can contribute/view it.

The colour is fantastic if its avoiding Color3 construction, it’s a great thing.
Regarding Discord, I have several questions along with some other stuff that I wanna disucss about with you: .ranu.

Looking forward to talking to you there!

1 Like

can you help me here please ethan?

I honestly have no idea why you’re having problems, i’ll do a quick test myself with the tile set and see what happens.

One thing I have immediately noticed with your tile sheet is that it has 1 pixel padding, which can be annoying to deal with when sampling each of the rects


EDIT: It appears for some reason the scaling math is completely wrong- Idk if it was always like this, but I am making a fix now

1 Like

It would also appear that the way it is being drawn has that “distorted” effect still. and I tried using the other image drawing functions (and forking them) to no avail. :broken_heart:

It would be really nice if I could get some help to get the function draw in Pixel Perfect with no distortion (No More DistortedTexturedTriangle Draws)

The distortion is going to be fixed! So far progress is going really well

1 Like

Hope has been restored in the world.

This is actually so cool, great job!

2 Likes

You have absolutely no idea how much this means to me… I spent WEEKS just figuring out what the problem was for the pixel rendering that I was burned out twice on it figuring out the method.
THANK YOU!

1 Like

Module Patch - v4.7.1


This release fixes a lot of rendering issues for image based drawing methods that use textured triangles internally.


  • Fixed jaggered texuring when using DrawTexturedTriangle, DrawDistortedImage, DrawImageRect and DrawRotatedImage

  • Fixed DrawImageRect not rendering correctly. Results should now be perfect and have no more issues!

  • FIxed DrawTexturedTriangle being 1 pixel off

  • Fixed ImageData:Clone() not 100% deep copying due to the new use of buffers


CanvasDraw4.7.1.b.rbxm (64.3 KB)


Here you go @DukeAunarky!

2 Likes