[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Thu Apr 05, 2012 9:18 pm

@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
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Mon Apr 16, 2012 6:51 pm

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 !
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Mon Apr 16, 2012 10:13 pm

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?
B
126
S
7
G
4
Posts: 185
Reputation: 7,233

Post » Tue Apr 17, 2012 6:27 am

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.
B
12
S
3
G
4
Posts: 55
Reputation: 3,186

Post » Wed Apr 18, 2012 10:49 am

This is exactly the function I'm looking for. Hope, that R0j0hound will incude it in R5.
B
19
S
5
G
4
Posts: 109
Reputation: 4,195

Post » Sat Apr 21, 2012 10:32 pm

@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.
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Post » Sun Apr 22, 2012 8:07 am

@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 !
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Mon Apr 30, 2012 4:41 pm

@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 !
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Mon Apr 30, 2012 5:28 pm

Canvas, my wmd of preference. :)
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue May 08, 2012 8:10 pm

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
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests