[cl-cairo2-cvs] r12 - tutorial
tpapp at common-lisp.net
tpapp at common-lisp.net
Tue Aug 14 07:53:12 UTC 2007
Author: tpapp
Date: Tue Aug 14 03:53:12 2007
New Revision: 12
Modified:
transformations.lisp
tutorial/ (props changed)
tutorial/example.lisp
tutorial/tutorial.tex
Log:
minor fixes in transformations code
Modified: transformations.lisp
==============================================================================
--- transformations.lisp (original)
+++ transformations.lisp Tue Aug 14 03:53:12 2007
@@ -5,13 +5,16 @@
;;;; cairo-matrix-init is not defined, as we have a structure in lisp
;;;; with an appropriate constructor
;;;;
-;;;; cairo_identity_matrix is reset-matrix
+;;;; cairo_identity_matrix is reset-trans-matrix
;;;;
;;;; functions that manipulate transformation matrices have
;;;; trans-matrix instead of matrix in their name
;;;;
;;;; cairo_matrix_transform_distance and cairo_matrix_transform_point
;;;; are simply transform-distance and transform-point
+;;;;
+;;;; cairo_matrix_init is not defined, make-trans-matrix will give
+;;;; you an identity matrix
;;;;
;;;; simple functions
@@ -22,7 +25,7 @@
(scale sx sy)
(rotate angle))
-(define-flexible (reset-matrix pointer)
+(define-flexible (reset-trans-matrix pointer)
(cairo_identity_matrix pointer))
@@ -30,7 +33,13 @@
;;;; transition matrix structure and helper functions/macros
;;;;
-(defstruct trans-matrix xx yx xy yy x0 y0)
+(defstruct trans-matrix
+ (xx 1d0 :type double-float)
+ (yx 0d0 :type double-float)
+ (xy 0d0 :type double-float)
+ (yy 1d0 :type double-float)
+ (x0 0d0 :type double-float)
+ (y0 0d0 :type double-float))
(defun trans-matrix-copy-in (pointer matrix)
"Copy matrix to a memory location."
@@ -108,7 +117,7 @@
(define-flexible (get-trans-matrix pointer)
(with-trans-matrix-out matrix-pointer
- (cairo_set_matrix pointer matrix-pointer)))
+ (cairo_get_matrix pointer matrix-pointer)))
(define-with-x-y user-to-device)
(define-with-x-y user-to-device-distance)
@@ -129,7 +138,6 @@
matrix-pointer
, at args)))))
-(define-matrix-init identity)
(define-matrix-init translate tx ty)
(define-matrix-init scale sx sy)
(define-matrix-init rotate radians)
Modified: tutorial/example.lisp
==============================================================================
--- tutorial/example.lisp (original)
+++ tutorial/example.lisp Tue Aug 14 03:53:12 2007
@@ -167,7 +167,7 @@
;; draw the hearts
(dotimes (i 200)
(let ((scaling (+ 5d0 (random 40d0))))
- (reset-matrix) ; reset matrix
+ (reset-trans-matrix) ; reset matrix
(translate (random width) (random height)) ; move the origin
(scale scaling scaling) ; scale
(rotate (deg-to-rad (- (random (* 2 max-angle)) max-angle 180))) ; rotate
Modified: tutorial/tutorial.tex
==============================================================================
--- tutorial/tutorial.tex (original)
+++ tutorial/tutorial.tex Tue Aug 14 03:53:12 2007
@@ -189,7 +189,8 @@
\verb!cairo_fill! (would conflict with \lstinline!cl:fill!)
& \lstinline!fill-path! \\
\verb!cairo_identity_matrix! (would
- conflict with matrix algebra packages)& \lstinline!reset-matrix! \\
+ conflict with matrix algebra packages)& \lstinline!reset-trans-matrix! \\
+ \verb!cairo_matrix_init_identity! & use \lstinline!(make-trans-matrix)!\\
\verb!cairo_matrix_transform_distance!
& \lstinline!transform-distance!\\
\verb!cairo_matrix_transform_point! &
@@ -320,10 +321,12 @@
cl-cairo2 defines the structure \lstinline!trans-matrix! with the
slots \lstinline!xx!, \lstinline!yx!, \lstinline!xy!, \lstinline!yy!,
-\lstinline!x0!, \lstinline!y0!. All the functions that use
-transformation matrices use this structure. Consequently,
-\verb!cairo_matrix_init! has no corresponding function in cl-cairo2:
-you can construct a translation matrix using
+\lstinline!x0!, \lstinline!y0!. The defaults for these slots give you
+the identity matrix.
+
+All the functions that use transformation matrices use this structure.
+Consequently, \verb!cairo_matrix_init! has no corresponding function
+in cl-cairo2: you can construct a translation matrix using
\lstinline!make-trans-matrix!.
Some functions are renamed, see Table~\ref{tab:naming}. Generally,
More information about the Cl-cairo2-cvs
mailing list