[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
11
Posts: 8
Reputation: 393

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
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

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
11
Posts: 8
Reputation: 393

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.
For game development / IT services contact - ravindra@actualconcepts.com

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
69
S
18
G
3
Posts: 332
Reputation: 6,783

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
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Wed Jan 06, 2016 12:39 am

Thank you.
For game development / IT services contact - ravindra@actualconcepts.com

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
69
S
18
G
3
Posts: 332
Reputation: 6,783

Post » Wed Jan 06, 2016 7:10 pm

B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Thu Jan 07, 2016 3:15 am

@R0J0hound, you are absolutely brilliant...Thanks a lot for this working example.
For game development / IT services contact - ravindra@actualconcepts.com

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
69
S
18
G
3
Posts: 332
Reputation: 6,783

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
97
S
22
G
176
Posts: 4,110
Reputation: 103,023

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests