Page 1 of 1
need help for converting something.
Posted:
Sun Sep 10, 2006 7:59 pm
by Game A Gogo
ok, i need help about converting a HSB value that are all 256 limit to an RBG value, anyone can please tell me how, if your going to run and find a solution, note me.
Note:
HSB meens Hue, Saturation and Brightness.
RBG meens Red, Green and Blue
and here is a screenshot of what im trying to make
[/img]
Posted:
Sun Sep 10, 2006 10:12 pm
by Kodo
Red: 162
Blue: 172
Green: 50
Try using Paintshop Pro, its pallet selection dialog displays RGB, HSB and HTML code for any colour.
Posted:
Mon Sep 11, 2006 11:28 pm
by Game A Gogo
i meen in real time frame by frame, so the "demo im making" can show you how to make a simple color picker window, i know that screen shots looks like a regular prgram, but its actually something i made, and i was only been able to make the HSB tables, and i need it so when you click aply it saves the rbg value to a file called colors.clr and yeah
Posted:
Tue Sep 12, 2006 12:21 am
by Kodo
Type
convert RBG to HSL (or HSB)
Into google, you'll get loads of info on the subject including info on how to convert from one to the other.
Posted:
Tue Sep 12, 2006 10:27 pm
by Game A Gogo
ok, ive found something, but the code only generate the RGB to HSL, but i need the oposite.
http://www.geekymonkey.com/Programming/ ... SL2RGB.htm
that is the link to the code, can anybody convert me that code for it??
Posted:
Thu Sep 14, 2006 10:15 pm
by Game A Gogo
ahh, i give up, since no one cares.
Posted:
Mon Sep 18, 2006 3:23 pm
by pioj
Hi, Game-aGogo
I saw sometime ago a blitzbasic code that fits your needs.
It's really easy to understand , by managin' with byte and rgb color values..
Dunno if GE have some POKE, and other pixel-like funtions, but I'll hope that...
Otherwise will be too many difficult..and slow.
Posted:
Mon Sep 18, 2006 11:15 pm
by Game A Gogo
ahh, blitzbasic, a long long time! well unfortunetly, GE dosn't support Basic like language, i need a specefic C# script that fits in whit GE, i know i will have to use the global code.
Posted:
Tue Sep 19, 2006 12:03 am
by makslane
For H, S, V from 0 to 255, put this code in the Global Code editor:
- Code: Select all
typedef struct stRGB
{
int r;
int g;
int b;
} RGB;
RGB HSV_to_RGB(double H, double S, double V)
{
//HSV values = From 0 to 255
//RGB results = From 0 to 255
//Code from: http://www.easyrgb.com/math.php?MATH=M21#text21
RGB out;
H /= 255.0;
S /= 255.0;
V /= 255.0;
if ( S == 0.0 )
{
out.r = out.g = out.b = V*255;
}
else
{
double var_h, var_i, var_1, var_2, var_3, var_r, var_g, var_b;
if(H == 1.0) H = 0.0;
var_h = H * 6;
var_i = (int)var_h;
var_1 = V * ( 1 - S );
var_2 = V * ( 1 - S * ( var_h - var_i ) );
var_3 = V * ( 1 - S * ( 1 - ( var_h - var_i ) ) );
if ( var_i == 0 ) { var_r = V ; var_g = var_3 ; var_b = var_1; }
else if ( var_i == 1 ) { var_r = var_2 ; var_g = V ; var_b = var_1; }
else if ( var_i == 2 ) { var_r = var_1 ; var_g = V ; var_b = var_3; }
else if ( var_i == 3 ) { var_r = var_1 ; var_g = var_2 ; var_b = V; }
else if ( var_i == 4 ) { var_r = var_3 ; var_g = var_1 ; var_b = V; }
else { var_r = V ; var_g = var_1 ; var_b = var_2; }
out.r = var_r * 255;
out.g = var_g * 255;
out.b = var_b * 255;
}
return out;
}
To use, just do:
- Code: Select all
RGB color = HSV_to_RGB(209, 142, 111);
The result will be: RGB = (105, 49, 111)
You can check the results at:
http://webdeveloper.earthweb.com/reposi ... 1/hex.html
Posted:
Tue Sep 19, 2006 12:28 am
by Game A Gogo
i cant get it to work
Posted:
Tue Sep 19, 2006 12:29 am
by makslane
What's happen?
Posted:
Tue Sep 19, 2006 2:40 pm
by pioj
Wow!
I feel like I could port most of my blitzbasic 2d games to this tool...
Does the script editor support all c++ functionality or is there any limitation?
(Would be great to have some functions to get/set Actor's Current Animation Speed, or more commands for tiles and clones..)
Il hope you'll release the next version soon...
Posted:
Tue Sep 19, 2006 4:37 pm
by makslane
There is not C++, but a C script engine.
You can copy and past almost anyl C code thats don't depends of external library.