Re: Drawing lines
- From: Olexiy Avramchenko <ath beast stu cn ua>
- To: Bryan Brown <bbrown saltmine radix net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Drawing lines
- Date: Wed, 25 Sep 2002 10:40:52 +0300
Bryan Brown wrote:
Taking a cue from a previous poster, I'd like to draw a line in a drawing
area between two points, starting where the user presses a mouse button
and ending where the button is released.
The code fragment in
http://www.radix.net/~bbrown/temp/draw_lines.c
almost does this. It reports the coordinates where the button is pressed
and released just fine. The problem is, when I uncomment-out the line
that calls gdk_draw_line I get a segmentation fault.
So, what's missing in the code fragment?
You have a bug there:
1. here's what you do
gdk_draw_line((GdkDrawable*)drawing_area, ...); /* *BUG* drawing_area
is GtkWidget, not GdkDrawable */
2. here's what you have to do:
gdk_draw_line(drawing_area->window, ...); /* all's ok:
drawing_area->window is valid drawable */
In addition, how can I get the color of each pixel in the line to be the
XOR of the pixel's original color? I want to do that so I can eventually
redraw the line and recover the original underlying image.
GdkGC has a field 'function'. You can change it via
gdk_gc_set_function(), so
gdk_gc_set_function(gc, GDK_XOR) is what you need.
gtk-doc/gdk/gdk-graphics-contexts.html#GDK-GC-SET-FUNCTION
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]