[PLUGIN] Canvas

Forum Home Forum Home > Construct 2 Development > Plugins for Construct 2
 Post Reply Post Reply Page  <1 56789 16>
Author
8,033 Rep
Post Options Post Options   Quote Zetar Quote  Post ReplyReply Direct Link To This Post Posted: 05 Apr 2012 at 9:18pm
@R0J0hound, I posted this in the General area, but then I thought you might want to address it here too...

I don't know if this has to do with your Plugin, but...

When I paste things into a blank canvas then spawn another canvas (during a Startup For Next Loop), It SEEMS like the new canvas is not blank like the original at startup. It is almost like the new one has the coppied Sprites in it...

CAPX: http://www.box.com/s/44f6c3b06132c4fe947c
Try HEX'N AROUND in the C2 Arcade!
Back to Top
5,297 Rep
Post Options Post Options   Quote Pode Quote  Post ReplyReply Direct Link To This Post Posted: 16 Apr 2012 at 6:51pm
Here's a small addition I have done to Canvas. The code is cleaner than what I send R0j0hound before, so I put here the archive.

If R0j0hound want to integrate it in the main branch, here's what I have done.
The code for the floodfilling is used from there http://www.williammalone.com/articles/html5-canvas-javascript-paint-bucket-tool/.
I also used the color.js helper from there http://www.phpied.com/rgb-color-parser-in-javascript/, because the algo uses the RGB value of a color, not a textual name (and there's no easy way to translate between the two in the HTML/JS world).
The code is pasted at the top of the runtime.js file. I added a "flood fill" action to the edittime.js, with the ID(22). It takes (x,y) and a color name as parameter. The floodfill is nearly instantaneous, but you must use images with clean edges !

You can see in the demo here how to do a "coloring book" app for kids.
(And you can see why you need a clean edges image !)

The .capx :
http://dl.dropbox.com/u/1412774/CanvasFloodFillDemo/CanvasFloodFillDemo.capx
The demo : http://dl.dropbox.com/u/1412774/CanvasFloodFillDemo/index.html
The plugin : http://dl.dropbox.com/u/1412774/CanvasFloodFillDemo/canvas.modPode.0.1.zip

As always, when I add some code to someone's plugin, I don't claim anything on his realisation, you need to thanks the original author here, R0j0hound !
Back to Top
5,545 Rep
Post Options Post Options   Quote Ugotsta Quote  Post ReplyReply Direct Link To This Post Posted: 16 Apr 2012 at 10:13pm
Thanks Pode! Hope to see that added by R0j0hound as I'm already using the Canvas plugin in several projects.

Do you think gradient fills would be difficult?
Check out Nibble in the HBGames Build and Win Construct 2 Contest!
Back to Top
1,351 Rep
Post Options Post Options   Quote tnewhook Quote  Post ReplyReply Direct Link To This Post Posted: 17 Apr 2012 at 6:27am
Thanks for all your work - to @R0J0hound, and everyone else who has helped with input, etc. I was wondering if there was a way to control the time - to let the user watch the line being drawn on the screen.
Back to Top
2,240 Rep
Post Options Post Options   Quote Epox Quote  Post ReplyReply Direct Link To This Post Posted: 18 Apr 2012 at 10:49am
This is exactly the function I'm looking for. Hope, that R0j0hound will incude it in R5.
Back to Top
7,061 Rep
Post Options Post Options   Quote R0J0hound Quote  Post ReplyReply Direct Link To This Post Posted: 21 Apr 2012 at 10:32pm
@Pode
Finally got around to reviewing your change. Your example wasn't working in Firefox, so I changed the color conversion to use another method.

Anyway updated the first post with R5.
Back to Top
5,297 Rep
Post Options Post Options   Quote Pode Quote  Post ReplyReply Direct Link To This Post Posted: 22 Apr 2012 at 8:07am
@R0J0hound : thanks for integrating it so quickly ! I remember know that I tested it on Chrome but don't remember if I tested it on Firefox, my bad.
Anyway, good news for everybody !
Back to Top
5,297 Rep
Post Options Post Options   Quote Pode Quote  Post ReplyReply Direct Link To This Post Posted: 30 Apr 2012 at 4:41pm
@newt asked for it on IRC, and it took me only two minutes, so here's a quick modification I added to the Canvas plugin : Overlap/Collison, like the Sprite plugin. In fact, I copy/pasted the code from the OnCollision and OnOverlap from the Sprite plugin inside the Canvas plugin (really dirty, but I don't have a lot of time to test & debug it...)

The demo : http://dl.dropbox.com/u/1412774/canvasCollisionOverlap/index.html
The .capx : http://dl.dropbox.com/u/1412774/canvasCollisionOverlap/canvas_Collision_Overlap_demo.capx
The plugin : http://dl.dropbox.com/u/1412774/canvasCollisionOverlap/canvas_Collision_Overlap.zip

I don't know if R0j0hound has the time to integrate it into the main branch, so don't forget to backup you original Canvas plugin !
Back to Top
16,524 Rep
Post Options Post Options   Quote newt Quote  Post ReplyReply Direct Link To This Post Posted: 30 Apr 2012 at 5:28pm
Canvas, my wmd of preference. :)
Back to Top
16,524 Rep
Post Options Post Options   Quote newt Quote  Post ReplyReply Direct Link To This Post Posted: 08 May 2012 at 8:10pm
Just a heads up with Pode's build. Everything seems to work, with the exception that my game will not work in IE on Kongregate. It just gets to the html5 logo and stops, no load apparently.
Ive tested IE against another C2 game on Kongregate, and that game ran fine... fairly sure it didn't use Canvas.
Perhaps it's something to do with the Iframe, as the standard Html5 export runs fine in all browsers, including IE, with no webgl of course.
Also no idea if the collision build has anything to do with it, as testing different versions on Kongregate is problematic at best.

Also, also wmd means weapon of mass distraction.:P
Back to Top
 Post Reply Post Reply Page  <1 56789 16>

Forum Jump Forum Permissions View Drop Down