update-state: handle nested lists.
[cl-vectors.git] / vectors.lisp
blob2617dd270d22ade98a91a7139cfb7426c1ef3234
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 (if (listp paths)
22 (dolist (path paths)
23 (update-state state path))
24 (let ((iterator (path-iterator-segmented paths)))
25 (multiple-value-bind (i1 k1 e1) (path-iterator-next iterator)
26 (declare (ignore i1))
27 (when (and k1 (not e1))
28 ;; at least 2 knots
29 (let ((first-knot k1))
30 (loop
31 (multiple-value-bind (i2 k2 e2) (path-iterator-next iterator)
32 (declare (ignore i2))
33 (line-f state
34 (point-x k1) (point-y k1)
35 (point-x k2) (point-y k2))
36 (setf k1 k2)
37 (when e2
38 (return))))
39 (line-f state
40 (point-x k1) (point-y k1)
41 (point-x first-knot) (point-y first-knot)))))))
42 state)