Re: Changing the background color of a window



Hi,

"j. santana" <jvgs osite com br> writes:

> I'm trying to change the background color of a window
> randomly, but I always get a black filled window,
> even though I get random values from g_rand.
> 
> (I'm trying this as an exercise in learning GTK.)

Colors are especially hard to get right so this is probably a bad
exercise to start with.

> What would be the best way to achieve this effect ?
> 
>      color.red = g_rand_int_range(rand,0,256);
>      color.green = g_rand_int_range(rand,0,256);
>      color.blue = g_rand_int_range(rand,0,256);

The red, green, blue fields of the GdkColor struct use 16 bit, so you
will want to use a range from 0 to 1<<16. This will however not
suffice since you need to allocate the color before it can be used.
If you really want to play with colors, you should read 
http://developer.gnome.org/doc/GGAD/sec-gdkvisual.html


Salut, Sven



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]