doodle / example.scm

(use matchable doodle)

(define *paint* #f)

(define red '(1 0 0 0.3))

 (lambda ()
   (set-font! "Vollkorn" 18 red)
   (text (/ doodle-width 2)
         (/ doodle-height 2) '("Welcome to doodle!"
                               "Click the left mouse button to draw circles"
                               "Press ESC to leave")
         align: #:center)))

 (lambda (events dt exit)
    (lambda (e)
      (match e
       (('mouse 'pressed x y 1)
        (set! *paint* #t)
        (filled-circle x y 10 red))
       (('mouse 'released x y 1)
        (set! *paint* #f))
       (('mouse 'moved x y)
        (when *paint*
          (filled-circle x y 10 red)))
       (('key 'pressed #\esc)
        (exit #t))
       (else (void))))

(new-doodle title: "Doodle paint" background: solid-white)