Re: gdk using other colors than black (black_gc) and white (white_gc)



You need to allocate your colors (red, blue, etc.).
(You can set the appropriate RGB fields in the color 
structure directly, or you can use gdk_color_parse()
to do that..but since your colors are all basic, RGB is
pretty simple.  Allocate the colors with 
gdk_colormap_alloc_color()).

You need a gc.   Then your allocated color must
be set as the gc's current drawing color before
you do the corresponding gdk_draw_whatever().
(gdk_gc_new(), and gdk_gc_set_foreground() will
suffice).

Without seeing your attempt, it's hard to know what
you did wrong....
Donna
----- Original Message ----- 
From: Thomas Amsler <tpamsler@ucdavis.edu>
To: <gtk-list@gnome.org>
Sent: Saturday, June 10, 2000 2:31 PM
Subject: gdk using other colors than black (black_gc) and white (white_gc)


> I am writing a little drawing program that is part of an application.  I
> would like to use eight colors, black, white, red, blue, green, yellow,
> cyan, and magenta.  I am able to use black and white by referring to
> black_gc and white_gc.  However, I had no luck so far to  get the
> remaining six colors.
> I use the following code in my application for black and white:
> 
> (snip)
> gdk_draw_rectangle (pixmap,
>    widget->style->black_gc,
>    TRUE,
>    update_rect.x, update_rect.y,
>    update_rect.width, update_rect.height);
> (snip)
> 
> The same code is used for white, substituting black_gc with  white_gc.
> How can I create the other colors? I tried to create a new graphics
> context representing the colors, but had no luck in doing so.  Any help
> is appreciated. Thank you very much.
> 
> 
> --  Thomas Amsler
> 
> "Imagination is more important than knowledge."
>         --Albert Einstein
> 
> 
> 
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 





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