Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,008 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Color Picker #405555
08/02/12 08:03
08/02/12 08:03
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
Hi,
for a draw function i want to create a color picker function
something like this
here
but i have no idea how to handle the RGB values
can someone help me please?

Re: Color Picker [Re: GameScore] #405556
08/02/12 09:12
08/02/12 09:12
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
if you can get the pixel position the mouse is over (and hopefully you can laugh ), use pixel_for_bmap() to get pixel data including colour.


Free world editor for 3D Gamestudio: MapBuilder Editor
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 Offline
Expert
MasterQ32  Offline
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!):
Code:
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


Visit my site: www.masterq32.de
Re: Color Picker [Re: MasterQ32] #405594
08/02/12 20:24
08/02/12 20:24
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
Thanks

Re: Color Picker [Re: GameScore] #406453
08/20/12 19:04
08/20/12 19:04
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
I got a problem to get the color of the panel bmap

here is my code

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.
Re: Color Picker [Re: GameScore] #406454
08/20/12 19:28
08/20/12 19:28
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
BMAP* hitMap = bmap_create("color_btn.png");

where do you show your bitmap?


Visit my site: www.masterq32.de
Re: Color Picker [Re: MasterQ32] #406456
08/20/12 19:51
08/20/12 19:51
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
same problem, crash

the colorpicker image is a large button on a panel
the idea is if the mouse is over the button
to change the mousecursor into a cross or a circle
and a arrow again after leave the button

and by hit the button the function will called where i get the
colorvalues from the bottonimage

Re: Color Picker [Re: GameScore] #406457
08/20/12 20:14
08/20/12 20:14
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
but is this panel in the top left corner of the screen?
exactly at (0|0)?


Visit my site: www.masterq32.de
Re: Color Picker [Re: MasterQ32] #406470
08/21/12 07:53
08/21/12 07:53
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
yeah the panel is on the top left side of the screen,
but you can move the panel with the mouse, like a real window
i saw the crash of the script is on different panel positions

Re: Color Picker [Re: GameScore] #406472
08/21/12 08:03
08/21/12 08:03
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
you have to check if the mouse is in the panel and then calculate the correct offset for your texture pixel
currently your accessing random memory (you move your bitmap, but you access it like it is in the top left corner)


Visit my site: www.masterq32.de
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1