1 registered members (Akow),
1,361
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Color Picker
#405555
08/02/12 08:03
08/02/12 08:03
|
Joined: Apr 2008
Posts: 245
GameScore
OP
Member
|
OP
Member
Joined: Apr 2008
Posts: 245
|
Hi, for a draw function i want to create a color picker function something like this herebut i have no idea how to handle the RGB values can someone help me please?
|
|
|
Re: Color Picker
[Re: sivan]
#405557
08/02/12 09:22
08/02/12 09:22
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
a normal rgb-color is a 3-dimensional value, so the first thing you need is the right part of your picker. you need an option to select the first dimension of your "color picker space" (The option buttons at R,G,B) if one of those buttons get clicked, create your left part, the "color picker space". simple iterate with a loop through all pixels and fill them with the corresponding value, best you create this space 256x256 pixels large example (no lite-c!):
for(x = 0; x < 256; x++) for(y = 0; y < 256; y++)
{
Color col;
switch(selectedFirstDimension)
case R:
col = color(rValue, x, y)
case G:
col = color(x, gValue, y)
case B:
col = color(x, y, bValue)
write_pixel(x, y, col)
}
now you can use sivans method to get the clicked pixel color
|
|
|
Re: Color Picker
[Re: MasterQ32]
#405594
08/02/12 20:24
08/02/12 20:24
|
Joined: Apr 2008
Posts: 245
GameScore
OP
Member
|
OP
Member
Joined: Apr 2008
Posts: 245
|
|
|
|
Re: Color Picker
[Re: GameScore]
#406453
08/20/12 19:04
08/20/12 19:04
|
Joined: Apr 2008
Posts: 245
GameScore
OP
Member
|
OP
Member
Joined: Apr 2008
Posts: 245
|
I got a problem to get the color of the panel bmap here is my code
void get_clr()
{
COLOR clr;
var format;
var pixel;
var clr_x,clr_y;
clr_x=mouse_pos.x;
clr_y=mouse_pos.y;
BMAP* hitMap = "color_btn.png";
var format=bmap_lock(hitMap,0);
var pixel=pixel_for_bmap(hitMap,clr_x,clr_y);
bmap_unlock(hitMap);
}
i got a script crash with this code
Last edited by GameScore; 08/20/12 19:04.
|
|
|
|