Re: 100 Different Colors
- From: Jan-Marek Glogowski <glogow fbihome de>
- To: Lola Smith <lola_smith55 yahoo com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: 100 Different Colors
- Date: Tue, 21 Jun 2005 13:32:41 +0200 (CEST)
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]