[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

simple graphics question



    Date: Tue, 18 Dec 1990 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

See the documentation for graphics:draw-line-driver, or more generally
Graphics Drivers.  Here's an example:

(defun scan-convert-line (x1 y1 x2 y2 &optional draw-end-point)
  (let ((result nil))
    (graphics:draw-line-driver x1 y1 x2 y2 draw-end-point
      (lambda (width height x y)
	(when ( width 0)
	  (push (list width height x y) result))))
    result))

On some systems, the results may differ from an on-screen representation
unless you're using scan conversion mode "Accurate".