[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Sat Feb 07, 2015 9:45 pm

@R0J0hound This looks really neat. Is there a way to export the canvas to a sprite so that I can save the sprite as a base 64 string?
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Sun Feb 08, 2015 10:00 am

TheWyrm wrote:@R0J0hound This looks really neat. Is there a way to export the canvas to a sprite so that I can save the sprite as a base 64 string?


Perhaps look at the paster plugin - I saw your other question - it's as easy as pasting your parts onto a paster object and either using that as the sprite right away or using a regular sprite with load image from url from the Paster object.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Sun Feb 08, 2015 10:10 am

@Somebody awesome. thanks for the info. I also discovered the SVG plugin with base64 strings.
ImageImageImageImageImage
B
19
S
5
G
1
Posts: 614
Reputation: 2,542

Post » Mon Feb 09, 2015 8:31 am

@TheWyrm
@Somebody

I had made a behavior rex_canvasext to load image in rojo's canvas plugin.
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Post » Tue Feb 17, 2015 9:56 pm

I would like to use the canvas plugin to create an image editor. My .capx does the following:

1. Load an image (.png or .jpg) to a sprite using the FileChooser plugin.
2. Move the sprite/resize it.
3. Paste the sprite into a canvas.
4. Use Canvas.imageURL to Base64 encode the contents of the canvas.
4. Upload the Base64 encoded image to a webserver.

Everything works fine for .png files loaded from a local directory, but I can't seem to Base64 encode the canvas if I start from a large .jpg file instead. Does anyone have any ideas for what I might be doing wrong?

Here is my .capx file:
imageuploader.capx


Here is a correctly Base64 encoded .png file:
Screen Shot 2015-02-17 at 3.49.25 PM.png


Here is an incorrectly Base64 encoded .jpg file:
Screen Shot 2015-02-17 at 3.53.33 PM.png
You do not have the required permissions to view the files attached to this post.
B
24
S
5
G
1
Posts: 71
Reputation: 2,389

Post » Wed Feb 25, 2015 6:03 am

Thanks for this hopefully these features ar integrated into C2 at some point :-)
B
5
Posts: 6
Reputation: 215

Post » Wed Feb 25, 2015 1:48 pm

Can't Believe something as simple as rgbaAt(x,y) isn't implemented in main construct yet. Gonna try out the plugin!
Follow my progress on Twitter
or in this thread Archer Devlog
B
23
S
8
G
11
Posts: 582
Reputation: 7,413

Post » Mon Mar 02, 2015 11:26 pm

Hey,

I've found a weird performance issue related to the Draw Circle action.

Basically, drawing a circle with a line width of >1 leads to a huge difference in draw calls. In my example, it's 95% CPU usage for draw calls vs 5% CPU usage, the only difference being a line width of 1.0001 vs. a line width of 1.

Am I missing something here? Or is drawing lots of circles always going to be inefficient?
You do not have the required permissions to view the files attached to this post.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Mar 02, 2015 11:51 pm

@sqiddster
My best guess is there may be an optimization in the browser for drawing lines with a width of 1. For the best performance with this plugin you'll want webgl set to off. That way it avoids the need to copy the entire canvas to a texture every frame.
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Tue Mar 03, 2015 12:11 am

@R0j0hound thanks, that was my guess too. I tried turning off webGL but didn't see any improvement. Anyway, my game requires webGL so that's out.

Can you think of an efficient way to draw lots of big thick circles? It's for a 'warp' effect at the end of my levels. Currently, I draw a whole load of big sprites which are empty circles. However naturally this absolutely slaughters the framerate because the GPU is drawing probably 90% empty pixels.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 5 guests