[PLUGIN] Canvas Forum Home > Construct 2 Development > Plugins for Construct 2 |
Post Reply
|
Page <12345 16> |
| Author | |
Post Options
Quote Reply
Posted: 15 Nov 2011 at 7:59pm |
|
|
Oh yeah you're completely right
I just tested with your idea But! mine works too, I modified the acts.pasteObject function this way :
And it erase perfectly, even if it's a bit weird now that I think about it. But yeah I'll stick with your idea... it's simpler Edited by Yann - 15 Nov 2011 at 8:00pm |
|
![]() |
|
Post Options
Quote Reply
Posted: 18 Nov 2011 at 8:43pm |
|
|
@R0J0hound: is it possible to add a function to you Canvas plugin to retrieve the canvas' image as data (I think the best is to retrieve a base64 text string) ?
I'm trying to add a property inside the canvas object, but it doesn't works... (In fact, I'm trying to implement a floodfill like there http://www.williammalone.com/articles/html5-canvas-javascript-paint-bucket-tool/, but perhaps I'm trying to climb a too high mountain... |
|
![]() |
|
Post Options
Quote Reply
Posted: 18 Nov 2011 at 8:54pm |
|
rgbaAt gets the color of the pixel at xy in the canvas. So you could to a nested loop like: for x=0 to canvas.width ->for y=0 to canvas.height -->system compare rgbaAt(loopindex("x"),loopindex("y"))= n do stuff Very slow though, and recursion will slow it a bit as well. |
|
![]() |
|
Post Options
Quote Reply
Posted: 18 Nov 2011 at 10:46pm |
|
|
newt: yes that could emulate the behavior. The problem is that a true floodfill needs to start in a spiral, starting from the clicked pixel. It needs a structure to hold all that, it's a headache to implement it outside the core of the script ;)...
|
|
![]() |
|
Post Options
Quote Reply
Posted: 18 Nov 2011 at 10:57pm |
|
|
For that you could use x+1, x-1, y+1, y-1, or sin, and cos.
Then there's the datastructures plug('s) to store things. |
|
![]() |
|
Post Options
Quote Reply
Posted: 19 Nov 2011 at 11:08am |
|
|
@newt: something that annoys me, is that the original floodfill implementation works only with recursion. And I don't think you can build something like that with events in C2...
|
|
![]() |
|
Post Options
Quote Reply
Posted: 19 Nov 2011 at 7:53pm |
|
|
Doesn't the "rgbaAt" expression do the trick?
There are other implementations of flood fill that don't use recursion: http://en.wikipedia.org/wiki/Flood_fill Here I used the array object to implement a queue to keep track of what points to fill next. http://dl.dropbox.com/u/5426011/examples%208/floodfill.capx |
|
![]() |
|
Post Options
Quote Reply
Posted: 19 Nov 2011 at 9:27pm |
|
|
@R0J0hound: it's slow as hell, but it's really, really, really impressive ! You're the best !
|
|
![]() |
|
Post Options
Quote Reply
Posted: 24 Nov 2011 at 10:06am |
|
|
HAHA Awesome Guys!
@R0j0hound you should really integrate the PasteDelete stuff officially... I've made this using the modified Canvas plugin from Yann in a few Minutes: CLICK ME!!! The black color is actually the layouts background color. The holes in the Canvas are made at start using PasteDelete :D EDIT: Updated with some more lemmings :D Runs pretty decent imo: http://dl.dropbox.com/u/45711709/LemTest2/index.html Edited by Ize - 24 Nov 2011 at 10:43am |
|
![]() |
|
Post Options
Quote Reply
Posted: 25 Nov 2011 at 5:47am |
|
I won't integrate it, because it will only work with the Sprite object if it's effect is set to "none". If the sprite uses any other effect PasteDelete won't work right. It also won't work with TiledBackground or Canvas objects either. Just give whatever object you want to delete from the canvas a "destination out" effect before pasting it. |
|
![]() |
|
Post Reply
|
Page <12345 16> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |