1 ;;;; $Id: illustrations.lisp,v 1.6 2007/10/01 16:24:10 xach Exp $
3 (defpackage #:vecto-illustrations
6 (in-package #:vecto-illustrations
)
14 (defun annotated-path (&rest points
)
16 (set-rgb-stroke 0.5 0.5 0.5)
17 (set-rgb-fill 0.5 0.5 0.5)
19 (dolist (point (remove-duplicates points
:test
'equal
))
20 (centered-circle-path (x point
) (y point
) 3))
22 (move-to (x (first points
)) (y (first points
)))
23 (dolist (point (rest points
))
24 (line-to (x point
) (y point
)))
28 (defun join-style (style file
)
29 (with-canvas (:width
160 :height
165)
32 (set-rgb-stroke 0 0 0)
39 (annotated-path '(20 .
20)
45 (defun cap-style (style file
)
46 (with-canvas (:width
40 :height
100)
49 (set-rgb-stroke 0 0 0)
55 (annotated-path '(20 .
20) '(20 .
80))
60 (defun closed-subpaths (closep file
)
61 (with-canvas (:width
160 :height
160)
64 (set-rgb-stroke 0 0 0)
74 (annotated-path '(20 .
20)
81 (defun dash-paths (array phase cap-style file
)
82 (with-canvas (:width
160 :height
40)
85 (set-rgb-stroke 0 0 0)
88 (set-dash-pattern array phase
)
89 (set-line-cap cap-style
)
93 (annotated-path '(20 .
20) '(140 .
20))
97 (defun simple-clipping-path (file &key clip-circle clip-rounded-rectangle
)
98 (with-canvas (:width
100 :height
100)
105 (set-rgb-fill 0.9 0.9 0.9)
106 (rectangle 10 10 80 80)
110 (centered-circle-path x0 y r
)
113 (when clip-rounded-rectangle
114 (rounded-rectangle 45 25 50 50 10 10)
118 (set-rgb-stroke 1 1 0)
119 (rectangle 10 10 80 80)
123 (set-rgb-stroke 0.5 0.5 0.5)
124 (set-dash-pattern #(5) 0)
126 (centered-circle-path x0 y r
)
128 (when clip-rounded-rectangle
130 (set-rgb-stroke 0.5 0.5 0.5)
131 (set-dash-pattern #(5) 0)
133 (rounded-rectangle 45 25 50 50 10 10)
137 (defun arc-demo (file)
141 (centered-circle-path x y
3)
143 (with-canvas (:width
150 :height
150)
145 (let* ((theta1 (* (/ pi
180) 20))
146 (theta2 (* (/ pi
180) 80))
147 (theta3 (/ (+ theta1 theta2
) 2))
149 (x1 (* (+ radius
10) (cos theta1
)))
150 (y1 (* (+ radius
10) (sin theta1
)))
151 (x2 (* (+ radius
10) (cos theta2
)))
152 (y2 (* (+ radius
10) (sin theta2
))))
154 (set-rgb-stroke 0.5 0.5 0.5)
155 (set-dash-pattern #(3 3) 0)
165 (set-rgb-stroke 1 0 0)
167 (arc 0 0 80 0 theta1
)
169 (set-rgb-stroke 0 0 1)
170 (arc 0 0 100 0 theta2
)
172 (set-rgb-stroke 0 1 0)
174 (line-to (* radius
(cos theta3
))
175 (* radius
(sin theta3
)))
178 (set-rgb-stroke 0 0 0)
179 (arc 0 0 radius theta1 theta2
)
181 (point (* radius
(cos theta1
))
182 (* radius
(sin theta1
)))
183 (point (* radius
(cos theta2
))
184 (* radius
(sin theta2
)))
187 (defun pie-wedge (file)
188 (with-canvas (:width
80 :height
60)
191 (angle1 (* (/ pi
180) 15))
192 (angle2 (* (/ pi
180) 45)))
196 (arc x y radius angle1 angle2
)
201 (with-canvas (:width
70 :height
70)
205 (angle2 (* (/ pi
180) 90)))
207 (set-rgba-fill 1 1 1 0.75)
208 (arc x y r1 angle1 angle2
)
209 (arcn x y r2 angle2 angle1
)
217 (defun make-illustrations ()
218 (cap-style :butt
"cap-style-butt.png")
219 (cap-style :square
"cap-style-square.png")
220 (cap-style :round
"cap-style-round.png")
221 (join-style :miter
"join-style-miter.png")
222 (join-style :bevel
"join-style-bevel.png")
223 (join-style :round
"join-style-round.png")
224 (closed-subpaths nil
"open-subpath.png")
225 (closed-subpaths t
"closed-subpath.png")
226 (dash-paths #() 0 :butt
"dash-pattern-none.png")
227 (dash-paths #(30 30) 0 :butt
"dash-pattern-a.png")
228 (dash-paths #(30 30) 15 :butt
"dash-pattern-b.png")
229 (dash-paths #(10 20 10 40) 0 :butt
"dash-pattern-c.png")
230 (dash-paths #(10 20 10 40) 13 :butt
"dash-pattern-d.png")
231 (dash-paths #(30 30) 0 :round
"dash-pattern-e.png")
232 (simple-clipping-path "clip-unclipped.png")
233 (simple-clipping-path "clip-to-circle.png" :clip-circle t
)
234 (simple-clipping-path "clip-to-rectangle.png" :clip-rounded-rectangle t
)
235 (simple-clipping-path "clip-to-both.png"
237 :clip-rounded-rectangle t
))