Re: About drawing primitives



Chris Nystrom <ccn olenska hn org> writes: 
> void
> color_foreground_set(int red, int green, int blue)
> {
>   color_fg.red = red * 255;
>   color_fg.green = green * 255;
>   color_fg.blue = blue * 255;
> 
>   gdk_color_alloc(colormap, &color_fg);
> 
>   gdk_gc_set_foreground(gc, &color_fg);

In GTK 2, it's best to omit the gdk_color_alloc, and use
gdk_gc_set_rgb_fg_color() instead of gdk_gc_set_foreground().  Then
the color will come from the preexisting RGB color cube and you won't
have to worry about deallocating it.

Another handy function is gdk_color_parse(), since it will parse a
string such as "red"

Havoc



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