Bugscript drawing library in Common Lisp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

21 lines
810 B

;;;; drawing-shortcuts.lisp
;;; Utilities for expressing drawing certain things in a faster manner.
(in-package #:bugscript)
;;; Additional drawing utilities
(defun polar-to-cartesian (cx cy radius degrees)
(let ((radians (* (- degrees 90) pi 1/180)))
(cons (+ cx (* radius (cos radians)))
(+ cy (* radius (sin radians))))))
(defun semicircle-to (cx cy radius start-angle end-angle &optional draw-to)
(destructuring-bind (sx . sy) (polar-to-cartesian cx cy radius start-angle)
(destructuring-bind (ex . ey) (polar-to-cartesian cx cy radius end-angle)
(svg:path
(if draw-to
(svg:line-to sx sy)
(svg:move-to sx sy))
(svg:arc-to radius radius
0 (if (<= (- start-angle end-angle) 180) 0 1) 0
ex ey)))))