[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Fri Nov 22, 2013 10:21 pm

Hi, this seems like a really useful plugin!

I'd like to know if I can use this to create procedurally generated terrain?

Something like Ski Safari

I managed to set it to a solid with the physics immovable property, but since paths can only be drawn onto the canvas and not with the canvas itself, is this possible?
B
24
S
6
G
3
Posts: 197
Reputation: 3,300

Post » Sun Nov 24, 2013 7:12 pm

Great Plugin

Thanks R0J0houndR0J0houn
B
44
S
15
G
6
Posts: 481
Reputation: 6,967

Post » Mon Nov 25, 2013 4:28 pm

@R0J0hound

Forgot to mention you. (My post is above)
B
24
S
6
G
3
Posts: 197
Reputation: 3,300

Post » Mon Nov 25, 2013 10:28 pm

@minaehap
Erasing is done by pasting an object with the "destination out" blend. To erase an abitrary shape you'll have to draw to another canvas give it the "destination" out blend and paste that to the original canvas.

@stachir
My Paster plugin allows you to draw a texture to an arbitrary quad, but it currently uses the whole texture instead of a sub-texture. But it appears doable with that.

@TwinTails
With this plugin you can draw whatever you want, so you have the visual aspect. The collisions isn't aren't really possible with this as it's collision polygon is always just a rotated rectangle so it's not good for collisions. There are capx' around that show ways to do per pixel collisions but it's you'll need to put actual sprites over it so it can be somewhat tricky. You could try yann's Polygon plugin as it handles the drawing and collision polygons.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Wed Nov 27, 2013 10:50 am

@R0J0hound Thanks, I will check them out :)
B
24
S
6
G
3
Posts: 197
Reputation: 3,300

Post » Sat Dec 14, 2013 12:50 am

I've discovered that the canvas.red/green/blue/alphaat expressions are very slow. I tried loading all of the image data into an array (which for a 500x750 image took like 15 minutes!) and discovered retrieving values from an array is far, far faster.

Is there any way that those expressions could be sped up? I know I don't understand how the plugin works behind the scenes, but could the plugin store the image data in an array in addition to or instead of the method it currently uses? Or perhaps could it export the r,g,b and a values as an array to json that could be loaded by the array plugin?

Edit: whoops, it does have to array as json. There seems to be a conflict though, as there are two asJSON expressions (one in the misc category and one in the canvas category), and the second one doesn't seem to be working.

Edit 2: I renamed the expression in the plugin and it doesn't seem to work. The debugger says the array is holding [object Object]. Can you explain how to use it? It said something in the js about that expression being experimental - or maybe I screwed it up by renaming it. If you could get it working or explain how it works, it would be much appreciated! :)Arima2013-12-14 01:57:52
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sat Dec 14, 2013 3:10 am

@Arima
That does sound like something is broken with it. I'll try to get it working in a day or so.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sat Dec 14, 2013 3:47 am

Awesome, thanks!
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Dec 15, 2013 7:19 pm

I looked into it and for now I'll leave it as is. Both .AsJSON expressions are using the expression I added and the default one that C2 added is not accessible for now.

For .ASJSON's use I explained it pretty well here:
http://www.scirra.com/forum/using-pixel-colors-as-reference-for-level-layouts_topic57020_post355255.html?KW=AsJSON#355255
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Tue Dec 17, 2013 12:29 am

Well, I tried, but I can't get it to work. Can you tell me what I'm doing wrong? All I get returned is 0. Capx.

Also, it would help if you added that formula to the description of the expression. Though, I think it would be a lot more intuitive if it were something like array.at(x location of pixel, y location of pixel, 0-3 representing r,g,b,a).Arima2013-12-17 00:34:25
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: Bitmichael and 2 guests