Users browsing this thread: 1 Guest(s)
The Spriter's Toolkit
#13
(04-18-2015, 04:34 AM)puggsoy Wrote:
(04-17-2015, 03:24 PM)Kelvin Wrote: As to the above question of how Palomine locates the closest color, I've come to realize that no matter how you slice it up, creating a one-dimensional array of colors just isn't gonna cut it. Color is three-dimensional, and I have to treat it as such, so I'm changing the color distance to actually use 3D distance.

Let me know how this goes. A while back I was trying to figure out how to go about this, I gave up but I plan to get back to it eventually. The problem is that you can't decide whether 0xFF0000 or 0x0000FF is closer to 0x00FF00, so the RGB colour space isn't reliable. Something like HSV might work, although I think I remember having issues with that as well.

Actually, you can. There are methods using bit shifting to separate red, green, and blue from each other into separate values, letting you turn a color into a 3D point. For instance, here's a function that splits a 24-bit color value into three 8-bit values:

Code:
SDL_Color makeColor(Uint32 color){

    SDL_Color newColor;

    newColor.r = color >> 16;
    newColor.g = color >> 8;
    newColor.b = color;

    return newColor;
};

If the recieving variable is only 8 bits long, it'll automatically trim off the extra bits, leaving you with just the parts you need for that one color.
Reply
Thanked by:


Messages In This Thread
The Spriter's Toolkit - by Kelvin - 04-12-2015, 10:23 PM
RE: The Spriter's Toolkit - by SmithyGCN - 04-12-2015, 10:44 PM
RE: The Spriter's Toolkit - by Kelvin - 04-13-2015, 07:32 AM
RE: The Spriter's Toolkit - by daemoth - 04-13-2015, 01:45 PM
RE: The Spriter's Toolkit - by puggsoy - 04-13-2015, 08:39 PM
RE: The Spriter's Toolkit - by Sketchasaurus - 04-14-2015, 05:04 AM
RE: The Spriter's Toolkit - by Kelvin - 04-14-2015, 09:14 PM
RE: The Spriter's Toolkit - by daemoth - 04-14-2015, 09:40 PM
RE: The Spriter's Toolkit - by TheShyGuy - 04-14-2015, 09:41 PM
RE: The Spriter's Toolkit - by Sketchasaurus - 04-14-2015, 10:01 PM
RE: The Spriter's Toolkit - by Kelvin - 04-17-2015, 03:24 PM
RE: The Spriter's Toolkit - by puggsoy - 04-18-2015, 04:34 AM
RE: The Spriter's Toolkit - by Kelvin - 04-19-2015, 03:56 PM
RE: The Spriter's Toolkit - by puggsoy - 04-20-2015, 03:56 AM
RE: The Spriter's Toolkit - by TheShyGuy - 04-20-2015, 09:35 AM
RE: The Spriter's Toolkit - by Kelvin - 04-20-2015, 01:49 PM
RE: The Spriter's Toolkit - by puggsoy - 04-21-2015, 02:06 AM
RE: The Spriter's Toolkit - by Kelvin - 05-04-2015, 08:48 AM
RE: The Spriter's Toolkit - by puggsoy - 05-08-2015, 09:05 AM
RE: The Spriter's Toolkit - by Kelvin - 05-10-2015, 07:04 AM
RE: The Spriter's Toolkit - by puggsoy - 05-11-2015, 03:56 AM
RE: The Spriter's Toolkit - by Kelvin - 05-11-2015, 07:35 AM

Forum Jump: