Re: How to get pixel values along a line?



That's a simple maths question, not GTK. If the user picks (x1,y1) and (x2,y2), then the points along that line conform to y = (y2 - y1)/(x2 - x1) * (x - x1) + y1. (I think!)

So plug in values for x from x1 to x2, and pull out y (with appropriate whole-number rounding.)

Hope that's vaguely helpful!
--
Andrew

Fredrik Persson wrote:
I writing a gtk application where I need to do the following; let the user
mark two pixels in a drawingarea (as you would if you were to draw a line
in, for example, the gimp) and then, somehow, have the pixel values along
that line be returned to me in some form. The goal is to present a graph to
the user with those pixel values.

The problem at hand is; how do I get those pixel values?

(And I'm writing this in pyhon, so if someone wants to provide code examples
in python, that would be great.)

TIA!

/Fredrik Persson


------------------------------------------------------------------------

_______________________________________________
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]