[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Tue Mar 03, 2015 3:33 pm

@sqiddster
Maybe a shader that draws the circles, since they're in a pattern. But really the gpu should be faster than that, and on my pc it is outside of web browsers.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Mar 10, 2015 11:05 pm

Hi, someone has suggested me this plugin for doing what I am trying to do:

I want to create a pixel count in an sprite ( or eventually canvas )

IE:

Player collides with Object > Is player bigger than the object ( has it more mass ) > Player gets bigger by amoount equal to 10% mass of the object that it has collided with.

And other way around, player shrinks if he hits something bigger than him.
B
3
Posts: 6
Reputation: 187

Post » Thu Mar 12, 2015 4:51 pm

@Uniqui22
Here's how yo can loop over the pixels to find how many are not-transparent:
how-do-i-check-how-much-of-a-span-class-posthilit-canvas-asjson-spa_p893960?#p893960

It's very slow though, so instead you could just calculate the approximate area of the sprite using the area of a circle or box.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Fri Mar 13, 2015 1:57 pm

Hi everyone, any possibility to "cancel" the Point Sampling with the canvas ?
I really need that for my project because it's full of pixel-art. Thanks !
B
4
Posts: 7
Reputation: 214

Post » Sat Mar 21, 2015 4:29 pm

Hello! I've hit upon a weird bug it seems with the Canvas plugin - it really doesn't seem to like the Roguelike plugin ( roguelike-plugin-c2-rot-js-interface_t118452 ) being added or used in the same project!

I'm getting this error: Uncaught TypeError: Cannot read property "pattern" of undefined, c2canvas_plugin.js, line 298 (col 34)

It seems to be caused by the action of "Paste Object In To Canvas" - if I comment those out then the game will run (although without the funky lighting effects I've got going, sorta defeating the point of it!). It will also run if I delete the "roguelike" entity from the game, which is also undesirable.

Is there an obvious way to fix this? :)
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 12
Reputation: 199

Post » Sun Mar 22, 2015 1:41 am

Hello! I'm a developer of the Roguelike plugin and am ready to fix any of its bugs. For now, we do not know if the bug is affecting the canvas or the roguelike plugin. So maybe, @R0J0hound could look into matters and fix the bug, if it's existing, or gives a clue how to improve the roguelike plugin. I'm using a canvas plugin for my main project and am also directly interested in making it work flawlessly.

Anyway, the roguelike plugin internally does not have anything to do with the canvas drawing or any other plugin, for that matter. The point is that it only gives you back a dictionary data structure that you can afterwards use to your liking. All it's other methods are just a manipulation of that dictionary. That said, the roguelike plugin should not be able to affect the workings of any other plugin or the C2 internals, for that matter.
B
6
S
2
Posts: 64
Reputation: 576

Post » Sun Mar 22, 2015 6:12 am

@UnusalCadence
What object are you pasting to the canvas?
When pasting an object to the canvas the object's non-webgl draw function is used. When webgl is on and the browser supports webgl, then plugins do stuff to get ready to draw with webgl, and have no need for the non-webgl draw function to work. For instance pasting a tilemap object with webgl on will have that problem. One solution is to set webgl to off in the project properties, but for most that's not an acceptable solution. You could use the Paster object instead as it doesn't have this issue.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Sun Mar 22, 2015 3:41 pm

It's a bit of an odd one as I'm aware the Roguelike object isn't more than a data array, so shouldn't have any bearing on Canvas! All I'm doing is pasting a light radius "Sprite" in to a Canvas, and then that Canvas in to a main Canvas. I've tried disabling WebGL but it produces the exact same error.

I'll have a go converting this over to the Paster plugin - I do have a version but I preferred how the additive lighting looked using Canvas. I also experimented with the performance on an older laptop with a mobile GPU, and Paster seemed to use up a lot more CPU compared to the Canvas implementation in fullscreen.
B
3
Posts: 12
Reputation: 199

Post » Sun Mar 22, 2015 4:13 pm

'Cause it might be helpful, here is how I use the paster object to implement the light system:

Image

P.S. If you do not see a complete picture, right click on it and choose view image, or similar (according to the browser you are using).
B
6
S
2
Posts: 64
Reputation: 576

Post » Mon Mar 23, 2015 2:23 am

@Lunarovich
I've had a look into it and the bug occurs when I use:
Code: Select all
for x in instances

in my code.

"instances" is an array so x just loops over the indices of the the array (0, 1, 2...). But when it fails x's value is "random". Looking in rot.min.js the Array object has these two methods added:
Array.prototype.random
Array.prototype.randomize

Adding methods to the Array object will break Array.foreach since it will now loop over the the methods after the indices. I can fix it in that particular case in my code, but any other plugin or part of C2 itself that uses Array.foreach will break as well.

The solution would be to do something like this to redefine the other prototype methods of the array to compensate.
http://kenegozi.com/blog/2009/04/13/jav ... prototype/
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests