graphics

Common Lisp graphics experiment
git clone git://git.entf.net/graphics
Log | Files | Refs

api.lisp (1326B)


      1 (uiop:define-package #:net.entf.graphics/draw
      2   (:use #:cl)
      3   (:local-nicknames (#:p #:net.entf.graphics/draw/protocol))
      4   (:export
      5    #:*sheet*
      6    #:with-sheet
      7    #:*brush*
      8    #:with-brush
      9    #:fill-path
     10    #:fill-rect
     11    #:fill-circle))
     12 (in-package #:net.entf.graphics/draw)
     13 
     14 (eval-when (:load-toplevel)
     15   (loop with proto-package = (find-package '#:net.entf.graphics/draw/protocol)
     16         for symbol being the external-symbols of proto-package
     17         for mine = (nth-value 1 (find-symbol (symbol-name symbol) *package*))
     18         unless (eq mine :external)
     19           do (import symbol)
     20           and do (export symbol)))
     21 
     22 (defparameter *sheet* nil)
     23 
     24 (defmacro with-sheet ((sheet) &body body)
     25   `(let ((*sheet* ,sheet))
     26      ,@body))
     27 
     28 (defparameter *brush* nil)
     29 
     30 (defmacro with-brush ((brush) &body body)
     31   `(let ((*brush* ,brush))
     32      ,@body))
     33 
     34 (defun fill-path (path &key (sheet *sheet*) (brush *brush*))
     35   (p:fill-path sheet brush path))
     36 
     37 (defun fill-rect (&key
     38                     (sheet *sheet*)
     39                     (brush *brush*)
     40                     (point (p:make-point 0 0))
     41                     (size (p:sheet-size sheet)))
     42   (p:fill-rect sheet brush :size size :point point))
     43 
     44 (defun fill-circle (point radius
     45                     &key (sheet *sheet*) (brush *brush*))
     46   (p:fill-circle sheet brush point radius))