[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: 100 Different Colors
- From: Lola Smith <lola_smith55 yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: Re: 100 Different Colors
- Date: Tue, 21 Jun 2005 08:10:09 -0700 (PDT)
Jan-Marek, thanks for your response.
I tried this:
>for (i=0; i<100; i++) {
> c.pixel = 0;
> c.red = G_MAXUINT16;
> c.blue = (i % 33 / 99) * G_MAXUINT16;
> c.green = i/99 * G_MAXUINT16;
> gdk_gc_set_rgb_fg_color( gc, &c );
> gdk_draw_rectangle (widget->window, gc, TRUE,
i*15,
> 0, 11, 11);
>}
But all the squares are red now, with the exception of
the last one (100th), which is yellow.
Do I have to change the value of c.red inside the for
loop as well? Maybe something related to i?
Btw, I am using gtk version 2.2, which didn't have
G_MAXUINT16, so I defined it like:
#define G_MAXUINT16 ((guint16) 0xffff)
Can someone help? Thaaank you!
--- Jan-Marek Glogowski <glogow fbihome de> wrote:
> Hi
>
> > I need to create 100 little squares and each of
> them
> > has to be a different color. They can't just be a
> > random color: they have to follow the colors of
> the
> > standard color spectrum/palette. For example, the
> > first one is dark blue, then lighter blue, ... ,
> > green, ... , red.
>
> Std. color spectrum? Maybe like the circle in the
> GtkColorSelectionDialog?
>
> Algo:
> r = max, g = 0, b = 0
> r = max , g = max, b = 0
> r = 0, g = max, b = 0
> r = 0, g = max, b = max
> r = 0, g = 0, b = max
> r = max, g = 0, b = max
> back to step 1
>
> See GtkColorSelection source
>
> From the GDK Manual:
>
> gdk_gc_set_rgb_fg_color () - set the foreground
> color of a GC using an
> unallocated color.
>
> GdkColor - red, green, blue ... is a value between 0
> and 65535, with 65535
> indicating full intensitiy.
>
> GdkGC *gc;
> GdkColor c;
>
> gc = gdk_gc_new (widget->window);
>
> for (i=0; i<100; i++) {
> c.pixel = 0;
> c.red = G_MAXUINT16;
> c.blue = (i % 33 / 99) * G_MAXUINT16;
> c.green = i/99 * G_MAXUINT16;
> gdk_gc_set_rgb_fg_color( gc, &c );
> gdk_draw_rectangle (widget->window, gc, TRUE,
> i*15,
> 0, 11, 11);
> }
>
> HTH
>
> Jan-Marek
>
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]