[PLUGIN] Canvas

2 favourites
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • R0J0hound - ah I'll give that a shot - thanks!!

  • I really shouldn't make plugins since I have no intention to edit the plugin to fix it. .

    R0J0hound, you shouldn't worry: other people learn from studying the code. If it's 'broken', then at least it provides some motivation for others to learn it (and hopefully modify it to their needs).

  • R0J0hound - unfortunately the default variables were already integers and not floats. It just keeps returning black (but when I set the "rgb(x,x,x)" to a text object, it looks the exact same as if I just set the color to "rgb(x,x,x)" using numbers (without variables)

    EDIT - I'm wrong. That worked strangely enough. Thank you!

  • R0J0hound - sorry, one more question. For some reason I got it to work using the int(), but I've just tried to recreate something I have in a different layout (which is working) and its literally the same code, but I can't figure out why it's not working in this new instance.

    I'm trying to just get the rgb of a canvas object based on the mouse position (the canvas object is being filled by gradient). I'm just doing "set text box to "rgb("&userGradient.redAt(Mouse.X, Mouse.Y)&","&userGradient.greenAt(Mouse.X, Mouse.Y)&","&userGradient.blueAt(Mouse.X, Mouse.Y)&")", but it's always returning rgb(0,0,0).

    I've tried int() on both individual mouse.x and mouse.y, as well as the entirety of the redAt, greenAt, etc.

    It just keeps returning 0 for all the paramenters.

    EDIT AGAIN (sorry)

    AhHA! Got it - I didn't know this breaks when you resize a canvas. For those who were wondering you fix by setting the mouse.x - canvas.x, and mouse.y - canvas.y for each.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Is the canvas object at the top left of the layout?

    Maybe use

    Mouse.x-canvas.bboxleft

    Mouse.y-canvas.bboxtop

    If it isn't.

  • R0J0hound

    How can I remove canvas objects in memory?

    when I create new canvas objects, memory going up.

    after I destroy all nothing change

  • I'm no longer updating plugin's but there may be a leak. Garbage collection doesn't happen immediately when something is destroyed so there's that. The runtime also does something called object recycling that doesn't actually delete the destroyed object so new objects can use it. That is so less garbage is created.

    I do know the main memory and cpu hog is every frame the canvas is drawn to I had it create a new webgl texture of it and discarded the previous. Honestly I've never been interested enough to improve that. The plugin was made before c2 had the webgl backend so maybe that explains that.

  • Hey, does it work in mobiles?

  • Test and see. It's based on an html5 canvas which is what and c2 game depends on to run.

    My use of C2 is limited so I've never tried mobile export myself.

  • R0J0hound

    I can make a Paint app with this?

  • It's a definite maybe. Some have made a few before.

  • The object moves along the path drawn with the canvas plugin, how to erase the part of the line which was passed by the object?

  • Do you guys figure out how to draw a filled circle (I am making a coloring apps)?

  • Does this plugin support Construct3?

  • hi. Is there any way to draw dashed line?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)