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

graphics in formmating-graph



    Date: Wed, 15 Jul 92 07:45:56 -0600
    From: drstrip@isrc.sandia.gov (David R. Strip)

    I would like to draw my own symbols for nodes in a function that uses
    formatting-graph/formatting-graph-node, but can't seem to figure out
    how to draw relative to the "current cursor position" (ie, where the
    node belongs.) Advice gratefully accepted.

Try graphics:with-room-for-graphics ... :fresh-line t, which gives a
primary cartesian quadrant whose top-left is at the current cursor
position and whose y=0 is far enough below that to contain what you
draw.

;;; -*- Mode: LISP; Syntax: Common-lisp; Package: USER; Base: 10; Lowercase: T -*-

(defun test ()
  (fresh-line)
  (dw:format-graph-from-root '(:circle (:square (:square)) (:circle (:triangle)))
			     #'(lambda (node stream)
				 (graphics:with-room-for-graphics (stream nil :fresh-line nil)
				   (ecase (first node)
				     (:circle
				       (graphics:draw-circle 25 25 20
							     :stream stream))
				     (:square
				       (graphics:draw-rectangle 5 5 45 45
								:stream stream))
				     (:triangle
				       (graphics:draw-triangle 25 45 5 5 45 5
							       :stream stream)))))
			     #'rest
			     ))