All Manuals > CLIM 2.0 User Guide > 5 Drawing in Color

5.6 Examples of Simple Drawing Effects

To draw in the foreground color, use the default, or specify :ink +foreground-ink+.

To erase, specify :ink +background-ink+.

To draw in color, specify :ink +green+, :ink (make-rgb-color 0.6 0.0 0.4), and so forth.

To draw an opaque gray, specify :ink (make-gray-color 0.25). This will draw a shade of gray independent of the window's foreground color. On a non-color, non-grayscale display this will generally turn into a stipple.

To draw a stipple of little bricks, specify :ink bricks, where bricks is defined as:

(make-rectangular-tile
 (make-pattern #2a(0 0 0 0 1 0 0 0 0)
               (0 0 0 1 0 0 0 0)
               (0 0 0 1 0 0 0 0)
               (1 1 1 1 1 1 1 1)
               (0 0 0 0 0 0 0 1)
               (0 0 0 0 0 0 0 1)
               (0 0 0 0 0 0 0 1)
               (1 1 1 1 1 1 1 1))
 (list +background+ +foreground+)) 8 8)

To draw a tiled pattern, specify :ink (make-rectangular-tile (make-pattern array colors)).

To draw a pixmap, use (draw-design (make-pattern array colors) medium).

5.6.1 Using Flipping Ink

(defun cmd-rubberband ()
  (let ((x1 0)        ; x1, y1 represents the fix point 
        (y1 0)
        (x2 0)        ; x2,y2 represents the point that is changing
        (y2 0)
        (mouse-button-press nil)
        ;; press to select pivot
        (stream (get-frame-pane *application-frame* 'main)))
    (tracking-pointer (stream)
                      (:pointer-button-press
                       (event x y )
                       (setf x1 x y1 y x2 x y2 y)
                       (draw-line* stream x1 y1 x2 y2
                                   :ink +flipping-ink+)
                       (setf mouse-button-press t))
                      (:pointer-motion
                       (window x y)
                       (when Mouse-button-press
                         ;;erase
                         (draw-line* stream x1 y1 x2 y2
                                     :ink +flipping-ink+)
                         ;; draw
                         (draw-line* stream x1 y1 x y
                                     :ink +flipping-ink+)
                         (setf x2 x y2 y)))
                      (:pointer-button-release
                       (event x y )
                       (cond
                        ((eq mouse-button-press t)
                         (return
                          (list x1 y1 x2 y2))))))))

CLIM 2.0 User Guide - 01 Dec 2021 19:38:57