I’m trying to let a player draw something on a canvas, but a while loop is too slow as well as mouse.Move and RenderStepped/Heartbeat.
How would I get the points to spawn faster and make it correct, or draw a line from point a to point b to make a line for each and every point? Thanks!
My code:
game:GetService("RunService").RenderStepped:Connect(function()
if canvas.Visible == true and cursor.Visible == true then
local x = math.abs(mouse.X - canvas.AbsolutePosition.X)
local y = math.abs(mouse.Y - canvas.AbsolutePosition.Y)
cursor.Position = UDim2.new(x/canvas.AbsoluteSize.X, 0, y/canvas.AbsoluteSize.Y, 0)
cursor.Size = UDim2.new(0, currentSize, 0, currentSize)
if mouseDown then
local paint = script.Paint:Clone()
paint.Position = UDim2.new(x/canvas.AbsoluteSize.X, 0, y/canvas.AbsoluteSize.Y, 0)
paint.Size = UDim2.new(0, currentSize, 0, currentSize)
paint.ImageColor3 = erasing and Color3.fromRGB(255, 255, 255) or currentColor
paint.Parent = paintContainer
end
end
end)
I also did greedy meshing to reduce part count so as you can see the image on the left only used 2 parts but this was done only after you saved the image not while you was drawing
What if you found a way to use part unions in order to smooth out edges
One of the first steps might be creating four different edges, concave 90 degree angle, convex 90 degree angle, concave inverse 90 degree angle, and convex inverse 90 degree angle.