[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Painting regions then saving them
- To: info-mcl@ministry.cambridge.apple.com
- Subject: Re: Painting regions then saving them
- From: zimmerma@rzdspc22.informatik.uni-hamburg.de (Kai Zimmermann)
- Date: 29 Apr 1994 10:07:39 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: University of Hamburg -- Germany
- References: <jona-270494155658@jona.ils.nwu.edu>
Kemi Jona (jona@ils.nwu.edu) wrote:
: In part of the application I am working on, I need to allow the user to
: paint arbitrary regions on the screen with a choice of 2 patterns (i.e.
: similar to MacPaint-style operations). I've got a rudimentary version of
: this working (code is at end of message).
: The part that I can't figure out is how to store what the user has drawn so
: that (a) I can save it between sessions, and (b) I can figure out what
: parts of the screen are painted with which pattern.
: I've tried using _OpenPicture, _OpenRgn & friends and have been able to get
: pict-handles and regions that capture what the user has drawn - but when I
: do that, the drawing doesn't appear on the screen.
: Thus, a better description of my problem is how does one display quickdraw
: commands *simultaneously* to both the screen and to a picture?
: Or is there a better way to do this than with _OpenPicture? Are regions
: the answer?
: Thanks for any pointers,
Hello Kemi,
I do not know wether pictures or regions are the better choice for
you, since I do not specificly know what you want to do.
But the answer on how to get a picture and window drawings, simultanously,
is quite easy. When you do a (start-picture ...) the cursor automatically
gets hidden. Just add a (pen-show ...) command to your code and
it works:
; Define a paint-window class
(defclass paint-window (window)
((picture :initarg pict :initform nil :accessor picture))
)
(defvar *current-pattern* *black-pattern*)
; Slightly change the event handler:
(defmethod view-click-event-handler ((win paint-window) where)
(if (eq (find-view-containing-point win where) win)
(with-focused-view win
; start a picture, the pen gets hidden:
(start-picture win)
; re-record old drawings, if there are:
(when (picture win)
(draw-picture win (picture win)))
; now make the pen visible
(pen-show win)
; your code:
(let ((penloc where)
(oldpenloc 0))
(without-interrupts
(loop
(unless (mouse-down-p) (return))
(unless (= penloc oldpenloc)
; slightly changed because
; with-pen-state seems to be not standard MCL
(set-pen-size win #@(15 15))
(set-pen-pattern win *current-pattern*)
(move-to win penloc)
(#_Lineto (point-h penloc) (point-v penloc)))
(setq oldpenloc penloc)
(setq penloc (view-mouse-position win)))))
; undo the show pen command from above
; because pen shown/hidden is not binary,
; rather it counts the number of show and hide commands.
(pen-hide win)
; save the new picture
(setf (picture win)
(get-picture win)))
(call-next-method)))
; small test: make some drawings to window xx
; then coy them to window yy.
(setf xx (make-instance 'paint-window))
(setf yy (make-instance 'paint-window))
(draw-picture yy (picture xx))
--
| /
| / ____
| / / \ ....
| /\ / \ ......
|/ \ | ) | ./..
| \ \ /> / Kai Zimmermann
| \_\____/ \_/ zimmerma@informatik.uni-hamburg.de