1 ;;; Copyright (c) 2007 Zachary Beane, All Rights Reserved
3 ;;; Redistribution and use in source and binary forms, with or without
4 ;;; modification, are permitted provided that the following conditions
7 ;;; * Redistributions of source code must retain the above copyright
8 ;;; notice, this list of conditions and the following disclaimer.
10 ;;; * Redistributions in binary form must reproduce the above
11 ;;; copyright notice, this list of conditions and the following
12 ;;; disclaimer in the documentation and/or other materials
13 ;;; provided with the distribution.
15 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
16 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 ;;; $Id: user-shortcuts.lisp,v 1.6 2007/09/21 01:39:07 xach Exp $
31 (defconstant +kappa
+ (* 4.d0
(/ (- (sqrt 2.0d0
) 1.0d0
) 3.0d0
))
32 "From http://www.whizkidtech.redprince.net/bezier/circle/, the top
33 Google hit for my vague recollection of this constant.")
35 (defun centered-ellipse-path (x y rx ry
)
36 "Add an elliptical subpath centered at X,Y with x radius RX and
38 (let ((cx (* rx
+kappa
+))
42 (curve-to (- x rx
) (+ y cy
)
46 (curve-to (+ x cx
) (+ y ry
)
50 (curve-to (+ x rx
) (- y cy
)
53 (curve-to (- x cx
) (- y ry
)
58 (defun centered-circle-path (x y radius
)
59 "Add a circular subpath centered at X,Y with radius RADIUS."
60 (centered-ellipse-path x y radius radius
))
62 (defun rectangle (x y width height
)
64 (line-to (+ x width
) y
)
65 (line-to (+ x width
) (+ y height
))
66 (line-to x
(+ y height
))
69 (defun rounded-rectangle (x y width height rx ry
)
70 ;; FIXME: This should go counter-clockwise, like RECTANGLE!
71 (let* ((x3 (+ x width
))
75 (xkappa (* rx
+kappa
+))
80 (ykappa (* ry
+kappa
+)))
85 (curve-to x0
(+ y2 ykappa
)
91 (curve-to (+ x2 xkappa
) y3
97 (curve-to x3
(- y1 ykappa
)
103 (curve-to (- x1 xkappa
) y0