1 (defpackage #:zpb-ttf-test
8 #:explicit-contour-points
)
9 (:local-nicknames
(:z
:zpb-ttf
)))
10 (in-package #:zpb-ttf-test
)
12 (defmacro contour
(&rest points
)
13 `(make-array ,(length points
)
15 (list ,@ (loop for
(x y c
) in points
16 collect
`(z::make-control-point
,x
,y
,c
)))))
18 (or (and (not a
) (not b
))
19 (and (typep a
'z
::control-point
)
20 (typep b
'z
::control-point
)
21 (eql (on-curve-p a
) (on-curve-p b
))
26 (and (= (length a
) (length b
))
29 always
(point= a b
))))
31 (defmacro check-dcs
* (contour &body points
)
32 `(let ((contour ,contour
)
35 (let ((x (pop points
)))
37 (destructuring-bind (x y
&optional c
) x
38 (z::make-control-point x y c
))))))
39 (do-contour-segments* (b c
) contour
40 (assert (point= b
(next-point)))
41 (assert (point= c
(next-point))))
42 (assert (null points
)))
47 (check-dcs* (contour (0 0 t
) (1 2) (3 4 t
) (5 6))
51 ;; starts on control point
52 (check-dcs* (contour (1 2) (3 4 t
) (5 6) (0 0 t
))
56 ;; only control points
57 (check-dcs* (contour (0 0) (2 2) (4 0) (2 -
2))
63 (defmacro check-dcs
(contour &body points
)
64 `(let ((contour ,contour
)
67 (let ((x (pop points
)))
69 (destructuring-bind (x y
&optional c
) x
70 (z::make-control-point x y c
))))))
71 (do-contour-segments (a b c
) contour
72 (assert (point= a
(next-point)))
73 (assert (point= b
(next-point)))
74 (assert (point= c
(next-point))))
75 (assert (null points
)))
81 (check-dcs (contour (0 0 t
) (1 2) (3 4 t
) (5 6))
83 (3 4 t
) (5 6) (0 0 t
))
85 ;; starts on control point
86 (check-dcs (contour (1 2) (3 4 t
) (5 6) (0 0 t
))
88 (3 4 t
) (5 6) (0 0 t
))
90 ;; only control points
91 (check-dcs (contour (0 0) (2 2) (4 0) (2 -
2))
92 (1 -
1 t
) (0 0) (1 1 t
)
94 (3 1 t
) (4 0) (3 -
1 t
)
95 (3 -
1 t
) (2 -
2) (1 -
1 t
))
97 (assert (contour= (contour (0 1) (2 3 t
))
98 (contour (0 1) (2 3 t
))))
100 (assert (not (contour= (contour (0 1 t
) (2 3 t
))
101 (contour (0 1) (2 3 t
)))))
102 (assert (not (contour= (contour (0 1))
103 (contour (0 1) (2 3 t
)))))
105 (assert (equalp (explicit-contour-points #()) #()))
108 (contour= (explicit-contour-points (contour (0 0 t
) (1 2) (3 4 t
) (5 6)))
109 (contour (0 0 t
) (1 2) (3 4 t
) (5 6))))
112 (contour= (explicit-contour-points (contour (1 2) (3 4 t
) (5 6) (0 0 t
)))
113 (contour (1 2) (3 4 t
) (5 6) (0 0 t
))))
116 (contour= (explicit-contour-points (contour (0 0) (2 2) (4 0) (2 -
2)))
117 (contour (0 0) (1 1 t
)