Re: [gtk-list] Newbie 'bout color.




>I cant figure out how to use different colors.
>Can someone give a simple example on how to draw a rectangle on a pixmap
>with a color specified by RGB-values.

Try this:



void draw_my_rectangle(GtkWidget *widget,gpointer data)
{

GdkColor *color;
GdkGC *gc;

gc = gdk_gc_new(window->window);
color = (GdkColor *)malloc(sizeof(GdkColor));
color->red = (gulong)(257 * 23);
color->green = (gulong) (257 * 121);
color->blue = (gulong)(257 * 232);
color->pixel = (gulong)(65536*23 + 256*121 + 232);
gdk_color_alloc(gtk_widget_get_colormap(window),color);
gdk_gc_set_foreground(gc,color);
gdk_draw_rectangle (pixmap,gc,TRUE,10,5,84,42);
gtk_widget_draw(window,NULL);

}






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