Updated make-circle-path to construct simpler path.
[cl-vectors.git] / vectors.lisp
blobc15dcb91281babdc634eefe3340505691f5aeaeb
1 ;;;; cl-vectors -- Rasterizer and paths manipulation library
2 ;;;; Copyright (C) 2007 Frédéric Jolliton <frederic@jolliton.com>
3 ;;;;
4 ;;;; This library is free software; you can redistribute it and/or
5 ;;;; modify it under the terms of the Lisp Lesser GNU Public License
6 ;;;; (http://opensource.franz.com/preamble.html), known as the LLGPL.
7 ;;;;
8 ;;;; This library is distributed in the hope that it will be useful, but
9 ;;;; WITHOUT ANY WARRANTY; without even the implied warranty of
10 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lisp
11 ;;;; Lesser GNU Public License for more details.
13 (defpackage #:net.tuxee.vectors
14 (:use #:cl #:net.tuxee.aa #:net.tuxee.paths)
15 (:nicknames #:vectors)
16 (:export #:update-state))
18 (in-package #:net.tuxee.vectors)
20 (defun update-state (state paths)
21 (dolist (path (if (listp paths) paths (list paths)))
22 (let ((iterator (path-iterator-segmented path)))
23 (multiple-value-bind (i1 k1 e1) (path-iterator-next iterator)
24 (declare (ignore i1))
25 (when (and k1 (not e1))
26 ;; at least 2 knots
27 (let ((first-knot k1))
28 (loop
29 (multiple-value-bind (i2 k2 e2) (path-iterator-next iterator)
30 (declare (ignore i2))
31 (line-f state
32 (point-x k1) (point-y k1)
33 (point-x k2) (point-y k2))
34 (setf k1 k2)
35 (when e2
36 (return))))
37 (line-f state
38 (point-x k1) (point-y k1)
39 (point-x first-knot) (point-y first-knot)))))))
40 state)