Posterize using Canvas and Tilemap

Get help using Construct 2

Post » Fri Nov 13, 2015 1:44 pm

I'm having some issues to find the easiest way to loop through a grid, setting the tiles in a tilemap based on the rgb-values of a sprite pasted onto the canvas..

At this time I use 32 values of gray.
I use : (canvas.redAt(x,y)+canvas.greenAt(x,y)+canvas.blueAt(x,y))/3 to get the gray value between 0 and 255 and based on that set the tile at that position to one of the 32 tiles (going from black to white)..

Although I think I am close to getting it to work the way I want to, I thought I might try here to get some input and pointers on ways to do it easier and/or quicker..

There might be some very fun ways to use this, or just the tilemap exported as json, I actually don't know..
Maybe it's just one of my crazy ideas..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Nov 13, 2015 2:13 pm

You could try other formulas:
http://docs.gimp.org/2.6/en/gimp-tool-desaturate.html

Does your tilemap go all the way from 0 to 255?

BTW Mind blow for the day:
You can use a canvas as a tilemap.

Also array's for each might simplify things if you're having issues with a nested loop.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Fri Nov 13, 2015 2:54 pm

Thanks @newt

Using the array-option was obviously the best way..
Obviously the loop does give a pause, but I kinda like being able to do this:

Canvas-Posterize

Now let's see if I can use it for the backgrounds in my semi-retro-adventure-game-idea...
If not, who cares..

Loading The tilemap from Json
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Nov 13, 2015 6:15 pm

@LittleStain

Just for your information (<--is this a valid sentence? Not a native speaker :/), firefox throws some script error, while chrome and NW.js works OK.

BTW you guys stop doing awesome things and make the rest of us look like idiots :mrgreen:
B
13
S
5
G
1
Posts: 116
Reputation: 1,805

Post » Fri Nov 13, 2015 6:24 pm

immortalx wrote:@LittleStain

Just for your information (<--is this a valid sentence? Not a native speaker :/), firefox throws some script error, while chrome and NW.js works OK.

BTW you guys stop doing awesome things and make the rest of us look like idiots :mrgreen:


Seems like Firefox has issues with webgl in this project..
When turning webgl off it works in Firefox too..
This might have to do with the canvas plugin..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: blue visionary, tarek2 and 10 guests