Re: Changing the background color of a window
- From: Sven Neumann <sven gimp org>
- To: jvictor mail com
- Cc: gtk-list gnome org
- Subject: Re: Changing the background color of a window
- Date: 25 Feb 2003 18:42:20 +0100
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]