[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Painting regions then saving them
- To: email@example.com
- Subject: Re: Painting regions then saving them
- From: firstname.lastname@example.org (Kai Zimmermann)
- Date: 29 Apr 1994 10:07:39 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: University of Hamburg -- Germany
- References: <email@example.com>
Kemi Jona (firstname.lastname@example.org) 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,
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
; 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)
; start a picture, the pen gets hidden:
; re-record old drawings, if there are:
(when (picture win)
(draw-picture win (picture win)))
; now make the pen visible
; your code:
(let ((penloc where)
(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.
; save the new picture
(setf (picture win)
; 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
| \_\____/ \_/ email@example.com