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

Re: Simple novice questions



On Thu Aug 19 18:27:44, Bill Coderre writes:
...
 what is the "best" way to plot a pixel in a window?
 I've got one that says:
 (defun dot (window color point)
  (pen-hide window)
  (move-to window point)
  (set-fore-color window color)
  (pen-show window)
  (line-to window point))
 
  Is there a simpler/faster/better way?

Your code will do exactly what you want but it won't change the
pixel permanently. As soon as you cover any portion of the window
containing the pixel with another window, it will be blank.

If you want the change to be permanent, you'll need to define
a view-draw-contents method for the window.

Even if you'll willing to accept the temporary nature of your
code, it would be better to use a defmethod:
(defmethod window-dot ((self window) &key color point)
   (when (and (numberp color) (numberp point)) ; you can do more checking
      ;  including checking that the window is color
      (with-focused-view self
	(#_PenNormal)   ;; same as (pen-normal self)
	(#_moveto :long point)  ;; same as (move-to self point)
	(#_forecolor color)
	(#_lineTo :long point))))
mark