|
8 | 8 | ;;; ___) | _ |/ ___ \| __/| |___ ___) |
|
9 | 9 | ;;; |____/|_| |_/_/ \_\_| |_____|____/
|
10 | 10 |
|
11 |
| -(defparameter *shape-cache-capacity* 1024) |
12 |
| - |
13 |
| -;; (defmacro define-cached-shape (name arglist &body body) |
14 |
| -;; `(function-cache:defcached (,name :cache-class 'function-cache:lru-cache |
15 |
| -;; :capacity *shape-cache-capacity*) |
16 |
| -;; ,arglist |
17 |
| -;; ,@body)) |
18 |
| - |
19 |
| -(defmacro define-cached-shape (name arglist &body body) |
20 |
| - `(defun ,name ,arglist |
21 |
| - ,@body)) |
22 |
| - |
23 | 11 | (defun point (x y)
|
24 | 12 | (declare (type real x y))
|
25 | 13 | (with-pen (make-pen :fill (pen-stroke (env-pen *env*)))
|
26 | 14 | (rect x y 1 1)))
|
27 | 15 |
|
28 |
| -(define-cached-shape make-line (x1 y1 x2 y2) |
| 16 | +(defun make-line (x1 y1 x2 y2) |
29 | 17 | (let* ((a (atan (- y2 y1) (- x2 x1)))
|
30 | 18 | (w (/ (or (pen-weight (env-pen *env*)) 1) 2))
|
31 | 19 | (dx (* 2 (sin a) w))
|
|
56 | 44 | (cdar (last lines)))
|
57 | 45 | nil)))
|
58 | 46 |
|
59 |
| -(define-cached-shape make-polyline (&rest coordinates) |
| 47 | +(defun make-polyline (&rest coordinates) |
60 | 48 | (multiple-value-bind (d+ d-)
|
61 | 49 | (div2-inexact (pen-weight (env-pen *env*)))
|
62 | 50 | (let* ((lines (edges (group coordinates) nil))
|
|
77 | 65 | (t (with-pen (flip-pen (env-pen *env*))
|
78 | 66 | (funcall (apply #'make-polyline coordinates))))))
|
79 | 67 |
|
80 |
| -(define-cached-shape make-rect (x y w h) |
| 68 | +(defun make-rect (x y w h) |
81 | 69 | (if (and (plusp w) (plusp h))
|
82 | 70 | (lambda ()
|
83 | 71 | (draw-shape
|
|
106 | 94 | y (* radial (- y (* x tangential)))))
|
107 | 95 | (nreverse vertices)))
|
108 | 96 |
|
109 |
| -(define-cached-shape make-ngon (n cx cy rx ry &optional (angle 0)) |
| 97 | +(defun make-ngon (n cx cy rx ry &optional (angle 0)) |
110 | 98 | (let ((vertices (ngon-vertices n cx cy rx ry angle)))
|
111 | 99 | (lambda ()
|
112 | 100 | (draw-shape :triangle-fan vertices vertices))))
|
|
116 | 104 | (type real cx cy rx ry angle))
|
117 | 105 | (funcall (make-ngon n cx cy rx ry angle)))
|
118 | 106 |
|
119 |
| -(define-cached-shape make-star (n cx cy ra rb &optional (angle 0)) |
| 107 | +(defun make-star (n cx cy ra rb &optional (angle 0)) |
120 | 108 | (let ((vertices (mix-lists (ngon-vertices n cx cy ra ra (+ 90 angle))
|
121 | 109 | (ngon-vertices n cx cy rb rb (- (+ 90 angle) (/ 180 n))))))
|
122 | 110 | (lambda ()
|
|
137 | 125 | (when (not (zerop r))
|
138 | 126 | (ellipse x y (abs r) (abs r))))
|
139 | 127 |
|
140 |
| -(define-cached-shape make-polygon (&rest coordinates) |
| 128 | +(defun make-polygon (&rest coordinates) |
141 | 129 | (list
|
142 | 130 | :triangles
|
143 | 131 | (triangulate coordinates)
|
|
0 commit comments