[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: simple graphics question
Date: Tue, 18 Dec 90 13:28 EST
From: bill@CASSIOPEIA.Mystech.DialNet.Symbolics.com (Bill Anderson)
hi,
is there a simple (ie built-in) way to obtain a list of indices (points) of a 2d-array that
would be "touched" if a line was drawn?
example:
2d-array bob 100x100
if we "draw" from 20,20 to 27,32 i would like a list of "touched" indices
like (20 20 21 23 ...) returned
basically the equivalent to graphics:compute-cubic-spline-points but for a simple line
-thanks
I think you want GRAPHICS:DRAW-LINE-DRIVER. Here's a short example: (CONS-TU
needs to do something with every point the line will pass through, but not
necessarily the endpoints - for your purposes, it's called on each pixel)
(GRAPHICS:DRAW-LINE-DRIVER (X (END1 SEG)) (Y (END1 SEG)) (X (END2 SEG)) (Y (END2 SEG)) NIL
#'(LAMBDA (WIDTH HEIGHT X Y)
(COND
((AND (EQL WIDTH 1) (EQL HEIGHT 1))
(CONS-TU X Y))
((EQL WIDTH 1)
(DOTIMES (N HEIGHT)
(CONS-TU X (+ N Y))))
((EQL HEIGHT 1)
(DOTIMES (N WIDTH)
(CONS-TU (+ N X) Y))))))
Hope this helps,
----
Brad Miller U. Rochester Comp Sci Dept.
miller@cs.rochester.edu {...allegra!rochester!miller}