Various enhancements and minor bug fixes
[clg] / cairo / cairo.lisp
1 ;; Common Lisp bindings for Cairo
2 ;; Copyright 2005 Espen S. Johnsen <espen@users.sf.net>
3 ;;
4 ;; Permission is hereby granted, free of charge, to any person obtaining
5 ;; a copy of this software and associated documentation files (the
6 ;; "Software"), to deal in the Software without restriction, including
7 ;; without limitation the rights to use, copy, modify, merge, publish,
8 ;; distribute, sublicense, and/or sell copies of the Software, and to
9 ;; permit persons to whom the Software is furnished to do so, subject to
10 ;; the following conditions:
11 ;;
12 ;; The above copyright notice and this permission notice shall be
13 ;; included in all copies or substantial portions of the Software.
14 ;;
15 ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 ;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 ;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 ;; $Id: cairo.lisp,v 1.8 2007-01-11 10:20:22 espen Exp $
24
25 (in-package "CAIRO")
26
27 (eval-when (:compile-toplevel :load-toplevel :execute)
28 (define-enum-type surface-format :argb32 :rgb24 :a8 :a1)
29 #?(pkg-exists-p "cairo" :atleast-version "1.2")
30 (define-enum-type content :color :alpha :color-alpha)
31 #?(pkg-exists-p "cairo" :atleast-version "1.2")
32 (define-enum-type surface-type
33 :image :pdf :ps :xlib :xcb :glitz :quartz :win32 :beos :directfb
34 :svg :nquartz :os2)
35
36
37 (define-enum-type status
38 :success :no-memory :invalid-restore :invalid-pop-group
39 :no-current-point :invalid-matrix :invalid-status :null-pointer
40 :invalid-string :invalid-path-data :read-error :write-error
41 :surface-finished :surface-type-mismatch :pattern-type-mismatch
42 :invalid-content :invalid-format :invalid-visual :file-not-found
43 :invalid-dash)
44
45 (define-enum-type fill-rule :winding :even-odd)
46 (define-enum-type line-cap :butt :round :square)
47 (define-enum-type line-join :miter :round :bevel)
48 (define-enum-type font-slant :normal :itaic :oblique)
49 (define-enum-type font-weight :normal :bold)
50
51 (define-enum-type operator
52 :clear :source :over :in :out :atop :dest :dest-over
53 :dest-in :dest-out :dest-atop :xor :add :saturate)
54
55 (define-enum-type antialias :default :none :gray :subpixel)
56 (define-enum-type extend :none :repeat :reflect)
57 (define-enum-type filter :fast :good :best :nearest :bilinear :gaussian)
58 (define-enum-type subpixel-order :default :rgb :bgr :vrgb :vbgr)
59 (define-enum-type hint-style :default :none :slight :medium :full)
60 (define-enum-type hint-metrics :default :off :on)
61
62 (defclass glyph (struct)
63 ((index
64 :allocation :alien
65 :initarg :index
66 :accessor glyph-index
67 :type unsigned-long)
68 (x
69 :allocation :alien
70 :initarg :x
71 :accessor glyph-x
72 :type double-float)
73 (y
74 :allocation :alien
75 :initarg :y
76 :accessor glyph-y
77 :type double-float))
78 (:metaclass struct-class))
79
80 (defclass font-face (proxy)
81 ()
82 (:metaclass proxy-class)
83 (:ref %font-face-reference)
84 (:unref %font-face-destroy))
85
86 (defclass font-options (proxy)
87 ((antialias
88 :allocation :virtual
89 :getter "font_options_get_antialias"
90 :setter "font_options_set_antialias"
91 :accessor font-options-antialias
92 :type antialias)
93 (subpixel-order
94 :allocation :virtual
95 :getter "font_options_get_subpixel_order"
96 :setter "font_options_set_subpixel_order"
97 :accessor font-options-subpixel-order
98 :type subpixel-order)
99 (hint-style
100 :allocation :virtual
101 :getter "font_options_get_hint_style"
102 :setter "font_options_set_hint_style"
103 :accessor font-options-hint-style
104 :type hint-style)
105 (hint-metrics
106 :allocation :virtual
107 :getter "font_options_get_hint_metrics"
108 :setter "font_options_set_hint_metrics"
109 :accessor font-options-hint-metrics
110 :type hint-metrics))
111 (:metaclass proxy-class)
112 (:ref %font-options-reference)
113 (:unref %font-options-destroy))
114
115 (defclass scaled-font (proxy)
116 ()
117 (:metaclass proxy-class)
118 (:ref %scaled-font-reference)
119 (:unref %scaled-font-destroy))
120
121 (defclass matrix (struct)
122 ((xx :allocation :alien :initarg :xx :initform 1.0
123 :accessor matrix-xx :type double-float)
124 (yx :allocation :alien :initarg :yx :initform 0.0
125 :accessor matrix-yx :type double-float)
126 (xy :allocation :alien :initarg :xy :initform 1.0
127 :accessor matrix-xy :type double-float)
128 (yy :allocation :alien :initarg :yy :initform 0.0
129 :accessor matrix-yy :type double-float)
130 (x0 :allocation :alien :initarg :x0 :initform 0.0
131 :accessor matrix-x0 :type double-float)
132 (y0 :allocation :alien :initarg :y0 :initform 0.0
133 :accessor matrix-y0 :type double-float))
134 (:metaclass struct-class))
135
136
137 (defclass text-extents (struct)
138 ((x-bearing :allocation :alien :reader text-extents-x-bearing :type double-float)
139 (y-bearing :allocation :alien :reader text-extents-y-bearing :type double-float)
140 (width :allocation :alien :reader text-extents-width :type double-float)
141 (height :allocation :alien :reader text-extents-height :type double-float)
142 (x-advance :allocation :alien :reader text-extents-x-advance :type double-float)
143 (y-advance :allocation :alien :reader text-extents-y-advance :type double-float))
144 (:metaclass struct-class))
145
146 (defclass pattern (proxy)
147 ((extend
148 :allocation :virtual
149 :getter "cairo_pattern_get_extend"
150 :setter "cairo_pattern_set_extend"
151 :accessor pattern-extend
152 :type extend)
153 (filter
154 :allocation :virtual
155 :getter "cairo_pattern_get_filter"
156 :setter "cairo_pattern_set_filter"
157 :accessor pattern-filter
158 :type filter)
159 (matrix
160 :allocation :virtual
161 :getter "cairo_pattern_get_matrix"
162 :setter "cairo_pattern_set_matrix"
163 :accessor pattern-matrix
164 :type matrix))
165 (:metaclass proxy-class)
166 (:ref %pattern-reference)
167 (:unref %pattern-destroy))
168
169
170 (defclass surface (proxy)
171 (#?(pkg-exists-p "cairo" :atleast-version "1.2")
172 (type
173 :allocation :virtual
174 :getter "cairo_surface_get_tyoe"
175 :reader surface-type
176 :type surface-type)
177 #?(pkg-exists-p "cairo" :atleast-version "1.2")
178 (content
179 :allocation :virtual
180 :getter "cairo_surface_get_content"
181 :reader surface-content
182 :type content))
183 (:metaclass proxy-class)
184 (:ref %surface-reference)
185 (:unref %surface-destroy))
186
187 (defclass context (proxy)
188 ((target
189 :allocation :virtual
190 :getter "cairo_get_target"
191 :reader target
192 :type surface)
193 (source
194 :allocation :virtual
195 :getter "cairo_get_source"
196 :setter "cairo_set_source"
197 :accessor source
198 :type pattern)
199 (antialias
200 :allocation :virtual
201 :getter "cairo_get_antialias"
202 :setter "cairo_set_antialias"
203 :accessor antialias
204 :type antialias)
205 (tolerance
206 :allocation :virtual
207 :getter "cairo_get_tolerance"
208 :setter "cairo_set_tolerance"
209 :accessor tolerance
210 :type double-float)
211 (fill-rule
212 :allocation :virtual
213 :getter "cairo_get_fill_rule"
214 :setter "cairo_set_fill_rule"
215 :accessor fill-rule
216 :type fill-rule)
217 (line-width
218 :allocation :virtual
219 :getter "cairo_get_line_width"
220 :setter "cairo_set_line_width"
221 :accessor line-width
222 :type double-float)
223 (line-cap
224 :allocation :virtual
225 :getter "cairo_get_line_cap"
226 :setter "cairo_set_line_cap"
227 :accessor line-cap
228 :type line-cap)
229 (line-join
230 :allocation :virtual
231 :getter "cairo_get_line_join"
232 :setter "cairo_set_line_join"
233 :accessor line-join
234 :type line-join)
235 (miter-limit
236 :allocation :virtual
237 :getter "cairo_get_miter_limit"
238 :setter "cairo_set_miter_limit"
239 :accessor miter-limit
240 :type double-float)
241 (font-matrix
242 :allocation :virtual
243 :getter "cairo_get_font_matrix"
244 :setter "cairo_set_font_matrix"
245 :accessor font-matrix
246 :type matrix)
247 (font-options
248 :allocation :virtual
249 :getter "cairo_get_font_options"
250 :setter "cairo_set_font_options"
251 :accessor font-options
252 :type font-options)
253 (font-face
254 :allocation :virtual
255 :getter "cairo_get_font_face"
256 :setter "cairo_set_font_face"
257 :accessor font-face
258 :type font-face)
259 (operator
260 :allocation :virtual
261 :getter "cairo_get_operator"
262 :setter "cairo_set_operator"
263 :accessor operator
264 :type operator)
265 (matrix
266 :allocation :virtual
267 :getter matrix
268 :setter "cairo_set_matrix"
269 :writer (setf matrix)
270 :type matrix)
271 )
272 (:metaclass proxy-class)
273 (:ref %reference)
274 (:unref %destroy))
275
276 (defclass image-surface (surface)
277 ((width
278 :allocation :virtual
279 :getter "cairo_image_surface_get_width"
280 :reader surface-width
281 :type int)
282 (height
283 :allocation :virtual
284 :getter "cairo_image_surface_get_height"
285 :reader surface-height
286 :type int))
287 (:metaclass proxy-class)
288 (:ref %surface-reference)
289 (:unref %surface-destroy))
290
291
292 ;; (defclass path (proxy)
293 ;; ()
294 ;; (:metaclass proxy-class))
295
296 )
297
298
299 ;;; Cairo context
300
301 (defbinding %reference () nil
302 (location pointer))
303
304 (defbinding %destroy () nil
305 (location pointer))
306
307 (defbinding (save-context "cairo_save") () nil
308 (cr context))
309
310 (defbinding (restore-context "cairo_restore") () nil
311 (cr context))
312
313 (defmacro with-context ((cr) &body body)
314 (let ((context (make-symbol "CONTEXT")))
315 `(let ((,context ,cr))
316 (save-context ,context)
317 (unwind-protect
318 (progn ,@body)
319 (restore-context ,context)))))
320
321 (defbinding status () status
322 (cr context))
323
324 (defun ensure-color-component (component)
325 (etypecase component
326 (float component)
327 (integer (/ component 256.0))))
328
329 (defbinding (set-source-color "cairo_set_source_rgba") (cr red green blue &optional (alpha 1.0)) nil
330 (cr context)
331 ((ensure-color-component red) double-float)
332 ((ensure-color-component green) double-float)
333 ((ensure-color-component blue) double-float)
334 ((ensure-color-component alpha) double-float))
335
336 (defbinding set-source-surface (cr surface &optional (x 0.0) (y 0.0)) nil
337 (cr context)
338 (surface surface)
339 (x double-float)
340 (y double-float))
341
342 (defun set-source (cr source)
343 (etypecase source
344 (pattern (setf (source cr) source))
345 (surface (set-source-surface cr source))
346 (list (apply #'set-source-color cr source))
347 (vector (apply #'set-source-color cr (coerce source 'list)))
348 (null (set-source-color cr 0.0 0.0 0.0))))
349
350 (defbinding set-dash (cr dashes &optional (offset 0.0)) nil
351 (cr context)
352 (dashes (vector double-float))
353 ((length dashes) int)
354 (offset double-float))
355
356 (defbinding (paint "cairo_paint_with_alpha") (cr &optional (alpha 1.0)) nil
357 (cr context)
358 (alpha double-float))
359
360 (defbinding mask () nil
361 (cr context)
362 (pattern pattern))
363
364 (defbinding mask-surface () nil
365 (cr context)
366 (surface surface)
367 (surface-x double-float)
368 (surface-y double-float))
369
370 (defmacro defoperator (name &optional clip-p)
371 (let ((iname (intern (format nil "%~A" name)))
372 (pname (intern (format nil "%~A-PRESERVE" name))))
373 `(progn
374 (defbinding ,iname () nil
375 (cr context))
376 (defbinding ,pname () nil
377 (cr context))
378 (defun ,name (cr &optional preserve)
379 (if preserve
380 (,pname cr)
381 (,iname cr)))
382 ,(unless clip-p
383 (let ((tname (intern (format nil "IN-~A-P" name)))
384 (ename (intern (format nil "~A-EXTENTS" name))))
385 `(progn
386 (defbinding ,tname () boolean
387 (cr context)
388 (x double-float)
389 (y double-float))
390 (defbinding ,ename () boolean
391 (cr context)
392 (x1 double-float :out)
393 (y1 double-float :out)
394 (x2 double-float :out)
395 (y2 double-float :out))))))))
396
397 (defoperator clip t)
398 (defoperator stroke)
399 (defoperator fill)
400
401 (defbinding reset-clip () nil
402 (cr context))
403
404 (defbinding copy-page () nil
405 (cr context))
406
407 (defbinding show-page () nil
408 (cr context))
409
410
411 ;;; Paths
412
413 (defbinding get-current-point () nil
414 (cr context)
415 (x double-float :out)
416 (y double-float :out))
417
418 (defbinding new-path () nil
419 (cr context))
420
421 #?(pkg-exists-p "cairo" :atleast-version "1.2")
422 (defbinding new-sub-path () nil
423 (cr context))
424
425 (defbinding close-path () nil
426 (cr context))
427
428 (defmacro defpath (name args &optional relative-p)
429 (flet ((def (name type)
430 `(progn
431 ,(when (eq type 'optimized-double-float)
432 `(declaim (ftype (function (context ,@(loop repeat (length args) collect 'double-float))) ,(first name))))
433 (defbinding ,name () nil
434 (cr context)
435 ,@(mapcar #'(lambda (arg) (list arg type)) args)))))
436
437 `(progn
438 ,(def name 'double-float)
439 ,(let ((name (intern (format nil "FAST-~A" name)))
440 (cname (gffi::default-alien-fname name)))
441 (def (list name cname) 'optimized-double-float))
442 ,@(when relative-p
443 (let* ((rel-name (intern (format nil "REL-~A" name)))
444 (fast-rel-name (intern (format nil "FAST-REL-~A" name)))
445 (cname (gffi::default-alien-fname rel-name)))
446 (list
447 (def rel-name 'double-float)
448 (def (list fast-rel-name cname) 'optimized-double-float)))))))
449
450
451 (defpath arc (xc yc radius angle1 angle2))
452 (defpath arc-negative (xc yc radius angle1 angle2))
453 (defpath curve-to (x1 y1 x2 y2 x3 y3) t)
454 (defpath line-to (x y) t)
455 (defpath move-to (x y) t)
456 (defpath rectangle (x y width height))
457
458 (defun circle (cr x y radius)
459 (arc cr x y radius 0.0 (* pi 2)))
460
461 (defbinding glyph-path (cr glyphs) nil
462 (cr context)
463 (glyphs (vector glyph))
464 ((length glyphs) int))
465
466 (defbinding text-path () nil
467 (cr context)
468 (text string))
469
470
471
472 ;;; Patterns
473
474 (defbinding (pattern-add-color-stop "cairo_pattern_add_color_stop_rgba")
475 (pattern offset red green blue &optional (alpha 1.0)) nil
476 (pattern pattern)
477 (offset double-float)
478 ((ensure-color-component red) double-float)
479 ((ensure-color-component green) double-float)
480 ((ensure-color-component blue) double-float)
481 ((ensure-color-component alpha) double-float))
482
483 (defbinding (pattern-create "cairo_pattern_create_rgba")
484 (red green blue &optional (alpha 1.0)) pattern
485 ((ensure-color-component red) double-float)
486 ((ensure-color-component green) double-float)
487 ((ensure-color-component blue) double-float)
488 ((ensure-color-component alpha) double-float))
489
490 (defbinding pattern-create-for-surface () pattern
491 (surface surface))
492
493 (defbinding pattern-create-linear () pattern
494 (x0 double-float)
495 (y0 double-float)
496 (x1 double-float)
497 (y1 double-float))
498
499 (defbinding pattern-create-radial () pattern
500 (cx0 double-float)
501 (cy0 double-float)
502 (radius0 double-float)
503 (cx1 double-float)
504 (cy1 double-float)
505 (radius1 double-float))
506
507 (defbinding %pattern-reference () nil
508 (location pointer))
509
510 (defbinding %pattern-destroy () nil
511 (location pointer))
512
513 (defbinding pattern-status () status
514 (pattern pattern))
515
516
517
518 ;;; Transformations
519
520 (defbinding translate () nil
521 (cr context)
522 (tx double-float)
523 (ty double-float))
524
525 (defbinding scale (cr sx &optional (sy sx)) nil
526 (cr context)
527 (sx double-float)
528 (sy double-float))
529
530 (defun scale-to-device (cr &optional keep-rotation-p)
531 (if keep-rotation-p
532 (multiple-value-call #'scale cr (device-to-user-distance cr 1.0))
533 (multiple-value-bind (x y)
534 (multiple-value-call #'user-to-device cr (get-current-point cr))
535 (identity-matrix cr)
536 (translate cr x y))))
537
538 (defbinding rotate () nil
539 (cr context)
540 (angle double-float))
541
542 (defbinding transform () nil
543 (cr context)
544 (matrix matrix))
545
546 (defbinding (matrix "cairo_get_matrix") () nil
547 (cr context)
548 ((make-instance 'matrix) matrix :in/return))
549
550 (defbinding identity-matrix () nil
551 (cr context))
552
553 (defbinding user-to-device () nil
554 (cr context)
555 (x double-float :in/out)
556 (y double-float :in/out))
557
558 (defbinding user-to-device-distance (cr dx &optional (dy dx)) nil
559 (cr context)
560 (dx double-float :in/out)
561 (dy double-float :in/out))
562
563 (defbinding device-to-user () nil
564 (cr context)
565 (x double-float :in/out)
566 (y double-float :in/out))
567
568 (defbinding device-to-user-distance (cr dx &optional (dy dx)) nil
569 (cr context)
570 (dx double-float :in/out)
571 (dy double-float :in/out))
572
573
574 ;;; Text
575
576 (defbinding select-font-face () nil
577 (cr context)
578 (family string)
579 (slant font-slant)
580 (weight font-weight))
581
582 (defbinding set-font-size () nil
583 (cr context)
584 (size double-float))
585
586 (defbinding show-text () nil
587 (cr context)
588 (text string))
589
590 (defbinding show-glyphs () nil
591 (cr context)
592 (glyphs (vector glyph))
593 ((length glyphs) int))
594
595 (defbinding font-extents () boolean
596 (cr context))
597
598 (defbinding text-extents (cr text &optional (extents (make-instance 'text-extents))) nil
599 (cr context)
600 (text string)
601 (extents text-extents :in/return))
602
603 (defbinding glyph-extents (cr glyphs &optional (extents (make-instance 'text-extents))) nil
604 (cr context)
605 (glyphs (vector glyph))
606 ((length glyphs) int)
607 (extents text-extents :in/return))
608
609
610 ;;; Fonts
611
612 (defbinding %font-face-reference () nil
613 (location pointer))
614
615 (defbinding %font-face-destroy () nil
616 (location pointer))
617
618 (defbinding font-face-status () status
619 (font-face font-face))
620
621
622
623 ;;; Scaled Fonts
624
625 (defbinding %scaled-font-reference () nil
626 (location pointer))
627
628 (defbinding %scaled-font-destroy () nil
629 (location pointer))
630
631 (defbinding scaled-font-status () status
632 (scaled-font scaled-font))
633
634 (defbinding scaled-font-extents (scaled-font &optional (extents (make-instance 'text-extents))) nil
635 (scaled-font scaled-font)
636 (extents text-extents :in/return))
637
638 (defbinding scaled-font-glyph-extents (scaled-font glyphs &optional (extents (make-instance 'text-extents))) nil
639 (scaled-font scaled-font)
640 (glyphs (vector glyph))
641 ((length glyphs) int)
642 (extents text-extents :in/return))
643
644 (defbinding %scaled-font-create () pointer
645 (font-face font-face)
646 (font-matrix matrix)
647 (ctm matrix)
648 (options font-options))
649
650 (defmethod allocate-foreign ((scaled-font scaled-font) &key font-face font-matrix cmt options)
651 (%scaled-font-create font-face font-matrix cmt options))
652
653
654
655 ;;; Font Options
656
657
658 (defbinding %font-options-copy () nil
659 (location pointer))
660
661 (defbinding %font-options-destroy () nil
662 (location pointer))
663
664 (defbinding font-options-status () status
665 (font-options font-options))
666
667 (defbinding %font-options-create () pointer)
668
669 (defmethod allocate-foreign ((font-options font-options) &rest initargs)
670 (declare (ignore initargs))
671 (%font-options-create))
672
673 (defbinding font-options-merge () nil
674 (options1 font-options :in/return)
675 (options2 font-options))
676
677 (defbinding font-options-hash () unsigned-int
678 (options font-options))
679
680 (defbinding font-options-equal-p () boolean
681 (options1 font-options)
682 (options2 font-options))
683
684
685
686 ;;; Surfaces
687
688 (defbinding %surface-reference () nil
689 (location pointer))
690
691 (defbinding %surface-destroy () nil
692 (location pointer))
693
694 (defbinding surface-create-similar () surface
695 (other surface)
696 (format surface-format )
697 (width int)
698 (height int))
699
700 (defbinding surface-finish () nil
701 (surface surface))
702
703 (defbinding surface-flush () nil
704 (surface surface))
705
706 (defbinding surface-get-font-options () nil
707 (surface surface)
708 ((make-instance 'font-options) font-options :in/return))
709
710 (defbinding surface-set-device-offset () nil
711 (surface surface)
712 (x-offset double-float)
713 (y-offset double-float))
714
715 (defbinding surface-status () status
716 (surface surface))
717
718 (defbinding %surface-mark-dirty () nil
719 (surface surface))
720
721 (defbinding %surface-mark-dirty-rectangle () nil
722 (surface surface)
723 (x int)
724 (y int)
725 (width int)
726 (height int))
727
728 (defun surface-mark-dirty (surface &optional x y width height)
729 (if x
730 (%surface-mark-dirty-rectangle surface x y width height)
731 (%surface-mark-dirty surface)))
732
733 #?(pkg-exists-p "cairo" :atleast-version "1.2")
734 (defbinding surface-set-fallback-resolution () nil
735 (surface surface)
736 (x-pixels-per-inch double-float)
737 (y-pixels-per-inch double-float))
738
739
740 ;; Image Surface
741
742 ;; Should data be automatically freed when the surface is GCed?
743 (defmethod allocate-foreign ((surface image-surface)
744 &key width height stride format data)
745 (if (not data)
746 (%image-surface-create format width height)
747 (%image-surface-create-for-data data format width height
748 (or
749 stride
750 (let ((element-size (cdr (assoc format '((:argb32 . 4) (:rgb24 . 4) (:a8 . 1) (:a1 1/8))))))
751 (ceiling (* width element-size)))))))
752
753
754 (defbinding %image-surface-create () image-surface
755 (format surface-format)
756 (width int)
757 (hegit int))
758
759 (defbinding %image-surface-create-for-data () image-surface
760 (data pointer)
761 (format surface-format)
762 (width int)
763 (hegit int)
764 (stride int))
765
766
767
768 ;;; PNG Surface
769
770 (defbinding image-surface-create-from-png (filename) image-surface
771 ((truename filename) pathname))
772
773
774
775
776 ;;; Matrices
777
778 (defbinding matrix-init () nil
779 (matrix matrix :in/return)
780 (xx double-float) (yx double-float)
781 (xy double-float) (yy double-float)
782 (x0 double-float) (y0 double-float))
783
784 (defbinding matrix-init-identity () nil
785 (matrix matrix :in/return))
786
787 (defbinding matrix-init-translate () nil
788 (matrix matrix :in/return)
789 (tx double-float)
790 (ty double-float))
791
792 (defbinding matrix-init-scale () nil
793 (matrix matrix :in/return)
794 (sx double-float)
795 (sy double-float))
796
797 (defbinding matrix-init-rotate () nil
798 (matrix matrix :in/return)
799 (radians double-float))
800
801 (defbinding matrix-translate () nil
802 (matrix matrix :in/return)
803 (tx double-float)
804 (ty double-float))
805
806 (defbinding matrix-scale () nil
807 (matrix matrix :in/return)
808 (sx double-float)
809 (sy double-float))
810
811 (defbinding matrix-rotate () nil
812 (matrix matrix :in/return)
813 (radians double-float))
814
815 (defbinding matrix-invert () nil
816 (matrix matrix :in/return))
817
818 (defbinding matrix-multiply () nil
819 (result matrix :out)
820 (a matrix)
821 (b matrix))
822
823 (defbinding matrix-transform-distance () nil
824 (matrix matrix :in/return)
825 (dx double-float)
826 (dy double-float))
827
828 (defbinding matrix-transform-point () nil
829 (matrix matrix :in/return)
830 (x double-float)
831 (y double-float))
832
833
834