Tuesday, September 14, 2010

color theory Part I : The tech

The first time you look at something like this

255, 94, 0

your like whaa?? But once you figure out what it is and you use it a while you start seeing it more like this







Or at least hopefully you do. Those three numbers separated by comas, is the RGB that describes a color to the computer. The first one is red, followed by green then blue. You combine those three colors and you will get the color your looking for.

Natively.

Theres another way for the computer to use those numbers. instead of "RGB" the alternative way is "HSL". (well to be honest the computer can do ANYTHING it wants with those numbers. But I really want to talk about HSL cause its fun.)

-The 'H' stands for "hue", which basically defines the color.
-The 'S' stands for "saturation", which basically means all white or all hue. or anywhere in between.
-The 'L' stands for "lightness", which also basically means all black or all hue. or (again) anywhere in between.

This is cool because using RGB can be very difficult if you, say, want to take a color and just make it darker. or would like to cycle through colors to create one of those psychedelic Jeff Minter style things. if you had the color defined as HSL you could just change the H "hue", and you got a different color with the same brightness and saturation. This is how i did the rainbow level in Cygnus.

Now, I know what your saying, Tony!, this sounds AWESOME but how do I convert to and from RGB and HSL? Well I found this c# code online a while ago,


And I converted it to c++ and using openFrameworks(OF is awesome!). This bit will take an RGB color and convert it to HSL...

// Given a Color (RGB Struct) in range of 0-255
// Return H,S,L in range of 0-1
static ofColor twRGB2HSL (ofColor rgb)
{
float r = rgb.r / 255.0f;
float g = rgb.g / 255.0f;
float b = rgb.b / 255.0f;
float v;
float m;
float vm;
float r2, g2, b2;

float h = 0; // default to black
float s = 0;
float l = 0;
v = max(r,g);
v = max(v,b);
m = min(r,g);
m = min(m,b);
l = (m + v) / 2.0;
if (l <= 0.0)
{
ofColor hsl;
hsl.r = h;
hsl.g = s;
hsl.b = l;
return hsl;
}
vm = v - m;
s = vm;
if (s > 0.0)
{
s /= (l <= 0.5) ? (v + m ) : (2.0 - v - m) ;
}
else
{
ofColor hsl;
hsl.r = h;
hsl.g = s;
hsl.b = l;
return hsl;
}
r2 = (v - r) / vm;
g2 = (v - g) / vm;
b2 = (v - b) / vm;
if (r == v)
{
h = (g == m ? 5.0 + b2 : 1.0 - g2);
}
else if (g == v)
{
h = (b == m ? 1.0 + r2 : 3.0 - b2);
}
else
{
h = (r == m ? 3.0 + g2 : 5.0 - r2);
}
h /= 6.0;

ofColor hsl;
hsl.r = h;
hsl.g = s;
hsl.b = l;
return hsl;
}



And this next bit will convert from HSL back to RGB...


// Given H,S,L in range of 0-1
// Returns a Color (RGB struct) in range of 0-255
static ofColor twHSL2RGB(float h, float sl, float l)
{
float v;
float r,g,b;

r = l; // default to gray
g = l;
b = l;
v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl);
if (v > 0)
{
float m;
float sv;
int sextant;
float fract, vsf, mid1, mid2;

m = l + l - v;
sv = (v - m ) / v;
h *= 6.0;
sextant = (int)h;
fract = h - sextant;
vsf = v * sv * fract;
mid1 = m + vsf;
mid2 = v - vsf;
switch (sextant)
{
case 0:
r = v;
g = mid1;
b = m;
break;
case 1:
r = mid2;
g = v;
b = m;
break;
case 2:
r = m;
g = v;
b = mid1;
break;
case 3:
r = m;
g = mid2;
b = v;
break;
case 4:
r = mid1;
g = m;
b = v;
break;
case 5:
r = v;
g = m;
b = mid2;
break;
}
}
ofColor rgb;
rgb.r = r * 255.0f;
rgb.g = g * 255.0f;
rgb.b = b * 255.0f;
return rgb;
}


The code isn't formatted very well here, but i'm lazy so I don't care.

Coming...(maybe)... color theory part II : The theory

Thursday, August 12, 2010

Battle Stations

"There comes a time in every man's life when he must kiss his wife and tell his family that he is leaving home and he will not be returning for he is going to war. "With what?", they may ask. And you'll tell them it is with one of the worst kinds of enemies, one that walks in the shadows, one that goes by no rules, one that preys on the innocent and weak. Your family may try to stop you. Mine did. That is why I killed them."

That was an excerpt from my recent novel "Stations Over Moonbase 94" for our new game 'Station'. What's that? Oh, right, I forgot, we have a new game!

Download: Station

Station can be summed up in six words: Space fights. Oh yeah. Space fights.

Some other descriptory words: It's a turn-based Strategy game on a 8x8 grid. If that sentence gets any kind of hot and/or bothered, please do download at GameJolt by means of the link above the paragraph above this paragraph.

Friday, June 25, 2010

Cygnus









It's an adventure game with Gravitar or Asteroid type controls. I've wanted to do a game like this for a while.

And I just uploaded it...ok ok I uploaded it like an hour ago, I went to go eat a sandwhich before I wrote this post.

You can download it here.

Wednesday, June 23, 2010

Pie in space




Intergalactic confections!


Sunday, June 20, 2010

screenshot?


from what? A new game?









maybe : ) Click on it to make it BIG!


Thursday, May 27, 2010

This Post Suffers From The Following Side Effects: Loss of Direction, A Questionable Existence, and Anal Leakage

Thought I'd update the blog and bump that Dio picture down. That things starting to creep me out.

So. How's everyone doin'? Let's see, what day is it today? Ah, yes, everyone geared up for Memorial Day? Uh, if you're in the US. I don't want to presuppose.

No news right now. Bad time to have a blog, really.

I'm thinking about doing some excersizing, perhaps some light aerobics. Sitting and eating isn't giving me the abs/buns/thighs/arms of steel I originally thought it would. I was thinking Cobb Salad, then push-ups, then coffee, then Krispy Kreme. No, wait, scratch that. I won't have any coffee.

Alright, I'll stop this while I'm behind.

Sunday, May 16, 2010