[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Tue Dec 29, 2015 3:34 pm

It seems that i cant pass vars or object expressions values into an action with x y parameters. I confirmed it by adding my own action into the edittime/runtime file. It only accepts number values only exactly. Is this a problem with the canvas plugin or Construct 2 itself? This is the code i placed, to add the clearRect function.

Edittime

AddAnyTypeParam("x", "the x position on canvas", "0");
AddAnyTypeParam("y", "the y position on canvas", "0");
AddAnyTypeParam("width", "the width from x", "0");
AddAnyTypeParam("height", "the height from y", "0");
AddAction(31, 0, "Erase canvas", "Canvas", "Erase at mouse x/y on canvas", "Erase at mouse x/y on canvas", "eraseWithColor");

Runtime

acts.eraseWithColor = function (x, y, width, height)
{
var ctx=this.ctx;
ctx.globalCompositeOperation = 'copy';
ctx.fillStyle = "rgba(0,0,0,0)";
ctx.clearRect(x,y,width,height);
this.runtime.redraw = true;
this.update_tex = true;
}
B
13
Posts: 8
Reputation: 443

Post » Tue Dec 29, 2015 4:03 pm

It probably has to do with using the "any" type. The sdk has number type params too that probably works. With "any" I'd assume you'd have to convert it to a number or something.
B
84
S
27
G
70
Posts: 4,933
Reputation: 49,558

Post » Tue Dec 29, 2015 6:08 pm

R0J0hound wrote:It probably has to do with using the "any" type. The sdk has number type params too that probably works. With "any" I'd assume you'd have to convert it to a number or something.


Actually i tried both, and with no luck. I even encapsulated it with int conversion, and it does nothing. I'll keep messing around, and see if i come up with something.
B
13
Posts: 8
Reputation: 443

Post » Tue Jan 05, 2016 7:39 am

@R0J0hound , I used canvas tool to create free hand curves and it works great. However the smoothing effect is missing in the free hand curves. Is there any way this can be converted to multiple beizer curves for smoothing effect as mentioned in this link - http://tavmjong.free.fr/INKSCAPE/MANUAL ... ating.html

I believe this will be a very useful feature and greatly enhance the user experience with free hand drawn curves. Any pointers on how I can achieve this will be much appreciated. Thanks.
B
76
S
20
G
3
Posts: 333
Reputation: 7,160

Post » Tue Jan 05, 2016 7:25 pm

@kmsravindra
I guess it is possible but I'm unfamiliar with a method. Probably some kind of linear regression or something. Also it's something you'd do outside of the plugin.
B
84
S
27
G
70
Posts: 4,933
Reputation: 49,558


Post » Wed Jan 06, 2016 7:10 pm

B
84
S
27
G
70
Posts: 4,933
Reputation: 49,558


Post » Mon Jan 25, 2016 12:04 pm

R0J0hound wrote:@MrShortee
Good to know. Fixed.


Awesome, thank you!
B
4
Posts: 6
Reputation: 216

Post » Fri Feb 19, 2016 6:01 am

@R0J0hound

Canvas plugin might not work correctly when official load, no image loaded back. -- test capx
(environment: C2-r222, window7 32bit, chrome browser)


BTW, it might improve performance that loading image data by putImageData method.
B
99
S
22
G
197
Posts: 4,209
Reputation: 113,783

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: amariscal and 1 guest