RE: drawing lines (help please)
- From: "Hugues Bernard" <hbernard gynov org>
- To: "Mike Holme" <M Holme doc mmu ac uk>
- Cc: <gtk-list gnome org>
- Subject: RE: drawing lines (help please)
- Date: Thu, 15 Mar 2001 23:04:54 +0100
> > > I'm finding it hard to find a simple example of drawing coloured
> > > lines.
<snip>
> > 1. Create a GdkGC (say mygc)
> > 2. Create and allocate a GdkColor
> > 3. Assign it to the foreground
<snip>
> > NB: if it doesnt help you, tell me, I had code example, but not
> right now ;-)
>
> I would like that help if you can find it. Thanks.
> Mike
See below.
this is modified from the scribble-simple example
(it draws a rectangle, but I think it s not so hard to adapt ;-)
Ciao
Hugues
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hugues Bernard
hbernard gynov org http://gynov.org
__
static void
draw_brush (GtkWidget *widget, gdouble x, gdouble y)
{
GdkRectangle update_rect;
/*added*/
GdkGC *temp_gc;
GdkColor color;
/* RGB value 0 <> 65535 */
color.red = 40000;
color.green = 20000;
color.blue = 10000;
/*/added*/
update_rect.x = x - 5;
update_rect.y = y - 5;
update_rect.width = 10;
update_rect.height = 10;
/*added*/
temp_gc = gdk_gc_new(widget->window);
gdk_color_alloc(gdk_window_get_colormap(widget->window),&color);
gdk_gc_set_foreground(temp_gc,&color);
/*/added*/
gdk_draw_rectangle (pixmap,
/*modified*/ temp_gc,
TRUE,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);
gtk_widget_draw (widget, &update_rect);
/*added*/
gdk_gc_unref(temp_gc);
/*/added*/
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]