[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Fri Nov 11, 2011 1:21 am

I got it, thanks.
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Post » Fri Nov 11, 2011 2:13 am

Awesome!!

This will be very useful!
Endless possibilities...

Is it possible to add a "line width" parameter to the "Draw line" action?
And maybe an automated "Draw circle" with position and radius parameters?
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Fri Nov 11, 2011 6:25 am

[QUOTE=Animmaniac] Awesome!!

This will be very useful!
Endless possibilities...

Is it possible to add a "line width" parameter to the "Draw line" action?
And maybe an automated "Draw circle" with position and radius parameters?[/QUOTE]

Paths have functions, line to, and arc to do those. Here's a capx that show how to do those.

Also @Rojohound I think ther may be an issue with setting color using rgba(). Seems alpha isn't changing.

Btw just realized with getrgba you've added the functionality of the image manipulator object.
Very nice idea.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Fri Nov 11, 2011 5:40 pm

[QUOTE=newt]Paths have functions, line to, and arc to do those.[/QUOTE]
I know paths can do it, but they need extra actions to draw things. I mean something more like the quick actions inside the "Canvas" category like "Draw Box", "Draw Line" and "Draw Point". At least I think they are supposed to be quick actions since they are somewhat redundant with Path's actions.

Rectangles and circles are probably the most used forms, so I think will be pretty handy to have a "Draw Circle" in a single action.
And since the "Draw Line" is already there, adding a "Line Thickness" param would just make it more complete.
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Fri Nov 11, 2011 10:25 pm

New version R3.
@newt
I just noticed that alpha values have to be in the range 0 to 1. I fixed the descriptions and rgbaAt to reflect that.

It will actually accept any CSS color value.
http://www.w3schools.com/cssref/css_colors_legal.asp
So you can use hsl or hsla also.

@Animmaniac
Added a line width parameter to the "draw line" action.
Also added a "draw circle" action. It only draws an outline, but if you want it filled use a "Fill path" action directly after.
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Fri Nov 11, 2011 10:58 pm

OK, that's probably better to work with in the long run.
Thanks for clearing that up.
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sat Nov 12, 2011 8:35 pm

Was hoping for this..This is great! Thanks
B
10
S
1
G
2
Posts: 47
Reputation: 1,615

Post » Sun Nov 13, 2011 3:28 pm

i like it,tnx man ^^
B
159
S
38
G
11
Posts: 229
Reputation: 17,361

Post » Mon Nov 14, 2011 10:32 pm

r0j0, thanks for this great plugin, I was trying to come up with a line/box/circle plugin but the Canvas is more than enough. Great work.

Just one feature, I'd like to have. But I wonder if it's feasible. Being able to erase part of the canvas, either by pasting a sprite or drawing something. I tried drawing lines or points with rgba(0,0,0,0) but it seems the drawing logic just add stuff.
So yeah basically, is it possible to have an "erase part of the canvas" feature?


Edit: after some research, maybe :

[code]acts.PasteErase = function(object)
{
// erase mode inside the canvas plugin object
this.ctx.globalCompositeOperation = "destination-out";

[acts.PastObject code]

// back to normal mode
this.ctx.globalCompositeOperation = "source-out";

}[/code]


Edit Bis:
HOHOHO that works =DYann2011-11-14 22:54:13
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Nov 15, 2011 7:24 pm

An erase action is not possible, globalCompositeOperation is set by the object being pasted. To do an erase effect, you would have to set the effect of the object you're pasting.

Sprite: set effect to "destination out"
Canvas: Paste "Sprite"
Sprite: set effect to "none"
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests