[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Sun Dec 18, 2011 11:26 pm

New update on first post.

New R4:
[Fix] Now works with WebGL. (thanks to Yann)
[Add] Additional hotspot locations top-right,top, etc...(thanks to Yann)
[Add] Paste Layer action(thanks to Yann)
[Change] Paste object/layer action now only paste visible objects.
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Sat Dec 24, 2011 7:57 am

Just a heads up.
Since setting color has to be a string you cant use variables, or loops like "rgb(loopindex("r"),loopindex("g"), loopindex("B"))"
The quotes within quotes makes C2's error checking kick in.
You can use double quotes, and it will be accepted, since its a string, but the browser cant make heads or tails of it. IE loopindex(""x"").

What does work is concatenating everything into one string like:
"rgb("&loopindex("n")&","&loopindex("n")&","&loopindex("n")&")"
Or
"rgb("&array.at(loopindex("x"),loopindex("y))&","&&array.at(loopindex("x"),loopindex("y))&","&&array.at(loopindex("x"),loopindex("y))&")""
and if you want to use values above 255, or below 0.. which you cant use
"rgb("&clamp(array.at(loopindex("x"),loopindex("y),0,255)&","&clamp(array.at(loopindex("x"),loopindex("y),0,255)&","&clamp(array.at(loopindex("x"),loopindex("y),0,255)&")""

Yeah, maybe I'll go learn to use hsl now.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Thu Jan 12, 2012 11:26 pm

Was just looking at some of the html5 attributes, and was wondering would it be possible to use a texture in paths?

Also any thoughts on adding the shadow attributes?
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Thu Jan 12, 2012 11:56 pm

the plugin doesn't work for me. i want to paste a sprite into the canvas, like in the demo capx. but this one just shows one wheel without any canvas, not like the exported html.

could you please add a working capx?
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Sat Jan 14, 2012 6:42 pm

Don't know if you have access to control the alpha channel and the color texture separately, but if you do I have some features to suggest.

I thought about a "Clear to Transparent" action with transparency control. This would fill the alpha with black with the respective opacity making the entire canvas a little more transparent. If this name doesn't sound so intuitive it could maybe be called something like "fill alpha" or "clear alpha".

This would allow to easily create trail effects without the need to spawn multiple canvases or objects, also saving some resources. With an every tick "Paste object to canvas" followed by a "Clear Canvas to 10% transparent", you could simply create trail effects.

Another idea is to allow drawing to the alpha directly. This would be a powerful feature opening a lot of possibilities. Instead of creating new actions for this, a dropdown parameter "Destination" could be added to all the "Draw" actions with the options of "Texture", "Alpha" or "Both" (being "Both" the default). This respectively would allow to choose to draw to the color texture only, the alpha only, or to both (like it currently is). The color parameters could be automatically converted to grayscale when "Alpha" is selected.

And lastly, just for consistency, I would suggest either making the "Draw Circle" action to draw it filled like the "Draw Box", or make the "Draw Box" draw it outlined like the "Draw Circle" (although I prefer the first option).

I think that's all I have to contribute for now. Keep up the great work!Animmaniac2012-01-14 18:48:07
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Sat Jan 14, 2012 8:13 pm

@newt
Textures would be useful but I have to work out a clean way to reference them in expressions.

@Animmaniac
You can do what you describe with effects.
For example use the "Destination out" effect to subtract alpha:
http://dl.dropbox.com/u/5426011/examples%208/canvasTrail.capx
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Thu Jan 26, 2012 6:38 am

Sorry to keep begging for stuff, but I was wondering if it would be possible to have the canvas export an image?
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Thu Jan 26, 2012 9:36 am

I would really like to export the canvas to a image aswell!
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Thu Jan 26, 2012 2:05 pm

The plugin has the expression "imageUrl" which stores the entire contents of the canvas as a png in base64 which you can copy paste into another browser window to view. You should be able to use the string returned by imageUrl with the plugin "load image from url" but saving the file to some server space is beyond my knowledge as I haven't dabbled with that aspect of the internet yet.
B
79
S
24
G
55
Posts: 4,755
Reputation: 41,273

Post » Thu Jan 26, 2012 2:47 pm

What about allowing the user to save those contents , like right click save as, or click an object, open a save dialog?
I know the regular context menu is disabled, so the latter would probably be best.
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: armaldio, matriax and 1 guest