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

this script i made does not seem to work that well, what am i doing wrong?

what script? we cannot help unless you at least provide code or an image/video of your problem

i forgot to paste it sorry. here is the script: `

Gui.Save_drawing.MouseButton1Click:Connect(function()
	-- Define the region to capture
	local PointA = Vector2.new(0, 0)
	local PointB = Vector2.new(255, 255)

	local ImageData = Canvas:CreateImageDataFromCanvas(PointA, PointB)
	local SaveObject = CanvasDraw.CreateSaveObject(ImageData)
	SaveObject.Name = "MyDrawing"
	SaveObject.Parent = Saves
end)
Gui.Load_drawing.MouseButton1Click:Connect(function()
	local LoadImage = Saves.MyDrawing
	local ImageData = CanvasDraw.GetImageData(LoadImage)
	Canvas:DrawImage(ImageData, Vector2.new(255, 255))
	Saves.MyDrawing:Destroy()
end)

`

maybe this is your problem. It looks like you are drawing outside the canvas entirely.

Image’s start at 1, 1 on the canvas. And if you canvas is 255x255, you are drawing your image almost entirely outside the canvas

image

Also you might wanna refer to API documentation sometimes as it describes the parameters of how the drawing functions work

1 Like

how do i know the bottom right corner of my canvas? im using. local Canvas = CanvasDraw.new(Frame)

You specify the resolution in the parameters of CanvasDraw.new().

This is mentioned on the API documentation also

local Canvas = CanvasDraw.new(Frame, Vector2.new(255, 255))

without this parameter, it will default to 100x100

1 Like

is it possible to rotate a image? i need to know if there’s a way to do so without using DrawTexturedTriangle for rotated images

The easiest and most efficient way to rotate an image is to use DrawDistortedImage with sin and cos rotation maths. It’s the simplest and honestly very fast too.

1 Like

Patch - v3.4.1

  • Fixed DrawImage/XY not drawing correctly when aspect ratio wasn’t square
  • Fixed some clipping errors with the image-based drawing functions
  • Other mild bug fixes and improvements
3 Likes

It would be more than nice if the module includes a way to enable some sort of layer containing a grid so people have an idea of where they’re placing down pixels (if using the free draw). Right now I have my own code inside the module, but it’s quite annoying having to add my changes to every update you make.

Is this something we could see added? Thanks

1 Like

Hmm. A grid wasn’t ever planned to be in the engine, as overlaying an imagelabel with tiling can be done outside the module. Just requires a bit of math for the resolution and aspect ratio

I might add a grid overlay as a property to the Canvas, that’s easy enough to do

1 Like

Yeah its a bit far fetched, but for people that want to use the free draw feature for just placing pixels, a grid property could be super helpful.
Creating my own is do-able but quite the hassle when it’s being updated a-lot.

Really solid module btw.

1 Like

I’m having a strange issue with the image importer plugin, roblox studio seems to freeze up and crash entirely when I try to open the plugin (i just left-clicked on it’s icon). I waited several minutes but it did nothing, I’m not really sure what’s wrong, am I somehow doing something wrong?

It just freezes simply when you click on the plugin button, without doing anything else? That’s weird…

All it should do is open the file explorer so you can select an image. This might be a windows or roblox related issue as the plugin works fine for everyone else I believe.

However, I’ll look into it anyways

Hey it seems to work now, I’m still not sure what was causing the issue but I think it was resolved after updating Roblox Studio, which I probably should have tried before making that reply.

1 Like

The image importer plug in doesn’t seem to support PNGs encoded in 8 bit format. Switching to 24 bit the image works.

Oh, yeah I was aware that the image importer may not work for types like that. The image importer uses @Maximum_ADHD’s PNG module, and I have no idea how it works tbh, and im not sure if there’s any other PNG module that may allow 8-bit formatting or not.

What program did you use to download an 8-bit format PNG? I didn’t even know that was thing

I used GIMP because I was rasterizing a image to be more performant

1 Like

Can Canvas Draw create layers?

As of this current version, no, but in the next update I plan to add a method which lets you create a blank image data, which can be used as a layer

1 Like