How to draw a primitive with one color and fill it with another?
- From: Sergey Parhomenko <sparhomenko yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: How to draw a primitive with one color and fill it with another?
- Date: Mon, 14 Apr 2008 07:05:20 -0700 (PDT)
Hello everyone.
I want to draw a red circle filled within with a green
color on my pixmap. I've set foreground and background
colors and passed TRUE as the "filled" parameter to
gdk_draw_arc(). But the circle is filled with the same
color as it is drawn, that is with the foreground
color - red.
How can I draw a red circle filled with green? The
relevant part of my code is below.
/* ... */
static GdkPixmap *pixmap = NULL;
void draw(GtkWidget* widget)
{
int width = widget->allocation.width;
int height = widget->allocation.height;
GdkGC *gc;
GdkColor colors[2];
int x = width / 2;
int y = height / 2;
int r = 30;
if (pixmap)
g_object_unref (pixmap);
pixmap = gdk_pixmap_new (widget->window,
width,
height,
-1);
gc = gdk_gc_new((GdkDrawable *)pixmap);
/* clearing to white: */
gdk_draw_rectangle (pixmap,
widget->style->white_gc,
TRUE,
0, 0,
width,
height);
gdk_color_parse("#ff0000", &colors[0]);
gdk_color_parse("#00ff00", &colors[1]);
/* By the way, can I get red and green GdkColor
faster, without these gdk_color_parse()? Are some
constants for this available? */
gdk_gc_set_rgb_fg_color(gc, &colors[0]);
gdk_gc_set_rgb_bg_color(gc, &colors[1]);
gdk_draw_arc(pixmap, gc, TRUE, x - r / 2, y - r / 2,
r, r, 0, 64 * 360);
}
/* ... */
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]