I'm using Allegro cl for windows. I'm looking for a code for mouse
drawing into a window. Then I wan't to be able to read from the
windows (drawing) like a x-y-graph into a list so I will get the X and
the Y of the window.
Does any one have ideas or code for drawing with the mouse.
Thank you.
ET Einarsson
········@hotmail.com (E T Einarsson) wrote:
> I'm using Allegro cl for windows. I'm looking for a code for mouse
> drawing into a window. Then I wan't to be able to read from the
> windows (drawing) like a x-y-graph into a list so I will get the X and
> the Y of the window.
> Does any one have ideas or code for drawing with the mouse.
you can use CLIM:
http://www.frank-buss.de/lisp/clim.html
but I don't understand what you mean with reading the X and Y of the
window. Do you want to print the coordinates of all points of a freehand-
drawing, or do you want to place only a few points with mouse clicks, which
are printed and connected by lines or a spline?
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
Frank Buss <··@frank-buss.de> wrote in message news:<············@newsreader2.netcologne.de>...
> ········@hotmail.com (E T Einarsson) wrote:
>
> > I'm using Allegro cl for windows. I'm looking for a code for mouse
> > drawing into a window. Then I wan't to be able to read from the
> > windows (drawing) like a x-y-graph into a list so I will get the X and
> > the Y of the window.
> > Does any one have ideas or code for drawing with the mouse.
>
> you can use CLIM:
>
> http://www.frank-buss.de/lisp/clim.html
>
> but I don't understand what you mean with reading the X and Y of the
> window. Do you want to print the coordinates of all points of a freehand-
> drawing, or do you want to place only a few points with mouse clicks, which
> are printed and connected by lines or a spline?
Excuse my english.
Actually I would like to be able to do both (all points and few points
with lines). Then I will have the coordinates in 2 lists X and Y.
ex. If I have two points and line between and coordinates of both
points I want to be able to calculate all points between, so I have
the process. I think there will have to be minimum space between
points.
Thanks, I will check out CLIM.
ET Einarsson
········@hotmail.com (E T Einarsson) wrote:
> Actually I would like to be able to do both (all points and few points
> with lines). Then I will have the coordinates in 2 lists X and Y.
why two lists? I think one list with pairs of coordinates is better.
> ex. If I have two points and line between and coordinates of both
> points I want to be able to calculate all points between, so I have
> the process. I think there will have to be minimum space between
> points.
if I understand it correctly, you want something like this:
some points, perhaps entered by mouse-clicks with a CLIM program:
(defparameter *p* '((100 100) (120 110) (140 100) (120 150)))
then you can print the lines between the points:
(defun print-lines (point-list)
(do ((p *p* (cdr p)))
((not (cdr p)))
(let ((p0 (car p))
(p1 (cadr p)))
(destructuring-bind ((x0 y0) (x1 y1)) (list p0 p1)
(format t "line: (~A ~A) - (~A ~A)~%" x0 y0 x1 y1)))))
(print-lines *p*) =>
line: (100 100) - (120 110)
line: (120 110) - (140 100)
line: (140 100) - (120 150)
to calculate all points between two points, you need a line calculating
function:
(defun print-line (p0 p1)
(destructuring-bind ((x0 y0) (x1 y1)) (list p0 p1)
(let* ((dx (- x1 x0))
(dy (- y1 y0))
(len (sqrt (+ (* dx dx) (* dy dy)))))
(dotimes (position (truncate len))
(let ((x (+ x0 (* (/ dx len) position)))
(y (+ y0 (* (/ dy len) position))))
(format t "~A ~A~%" x y))))))
(print-line '(100 100) '(110 107)) =>
100.0 100.0
100.81923192051904 100.57346234436334
101.63846384103807 101.14692468872666
102.45769576155712 101.72038703308999
103.27692768207616 102.29384937745331
104.09615960259521 102.86731172181665
104.91539152311424 103.44077406617997
105.73462344363328 104.0142364105433
106.55385536415233 104.58769875490663
107.37308728467137 105.16116109926996
108.1923192051904 105.73462344363328
109.01155112570945 106.30808578799662
Note: the line algorithm is not very good, you should use bresenham or
other fast algorithms. If you want curves between the points, you should
use splines, like this:
http://www.frank-buss.de/spline.html
http://groups.google.de/groups?threadm=c6oecu%24rl1%241%40pegasus.csx.cam.ac.uk
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de