XSColor, XSNamedColor

SYNTAX

	pixel=XSColor(wid,red,green,blue)

	XSWidget *wid;
	unsigned int pixel,red,gree,blue; 

	pixel=XSNamedColor(wid,colorname)

	XSWidget *wid;
	unsigned int pixel;
	char *colorname;

DESCRIPTION

XSColor calculate or query the screen for the more aproximated color defined by values red, green and blue. For depths 24, 16 and 15, a fast color calculation is returned (this operation can be unsafe in mixed big/litle endian networks), for any other depth colors are allocated in the screen.

XSNamedColor will try to convert a ASCII color name to XSColor. A list of valid colornames is available here. The RGB value returned by XSNamedColor is precise only in 24-bit depths and an aproximation in any other depth.

Example

#include <xstep.h>
#include <stdlib.h>

int main(int argc,char **argv) {

	XSWidget *d1,*w1,*l1;
	
	d1=XSDesktop(getenv("DISPLAY"),argv,argc);
	w1=XSWindow(d1,0,0,400,400,"color example");
	
	l1=XSLabel(w1,8+108*0,8,100,100,"red",0);
	l1->bgcolor=XSNamedColor(d1,"red");

	l1=XSLabel(w1,8+108*1,8,100,100,"green",0);
	l1->bgcolor=XSNamedColor(d1,"green");

	l1=XSLabel(w1,8+108*2,8,100,100,"blue",0);
	l1->bgcolor=XSNamedColor(d1,"blue");

	XSButton(w1,-8,-8,72,24,"Close",XSWindowClose);
	
	while(XSCheckEvent(d1,XS_BLOCK));

	return 0;
}