[mcclim-devel] Problems with compose-xxx-with-yyy transformation functions

Paul Werkowski pw at snoopy.mv.com
Fri Dec 9 13:44:03 UTC 2005


(in-package :clim-user)

(defun t1 ()
  ;; works same on mcclim and lw
  (let* ((a (make-translation-transformation 10 10))
         (b (make-scaling-transformation 2 2)))
    (multiple-value-bind (x y)
        ;; Spec says;
        ;; b (scaling) first, then a (translation)
        (transform-position (compose-transformations a b) 1 1))
    (format t "T1 => ~a ~a~%" x y)
    (assert (= 12 x y))))

(defun t2 ()
  ;; LW CLIM gives (values 12 12), McCLIM gives (values 22 22) ??
  (let ((a (compose-transformation-with-translation
            ;; Spec says;
            ;; transformation (scaling) first, then translation
            (make-scaling-transformation 2 2) 10 10)))
    (multiple-value-bind (x y)(transform-position a 1 1)
      (format t "T2 => ~a ~a~%" x y)
      (assert (= 12 x y)))))

#+bugged-McCLIM definition
;;; oops, order is reversed!
(defun compose-transformation-with-translation (transformation dx dy)
  (compose-transformations transformation (make-translation-transformation
dx dy)))

;;;;; Proposed fixes

#+McCLIM
(progn
(defun compose-translation-with-transformation (transformation dx dy)
  (compose-transformations transformation (make-translation-transformation
dx dy)))

(defun compose-scaling-with-transformation (transformation sx sy &optional
origin)
  (compose-transformations transformation (make-scaling-transformation sx sy
origin)))

(defun compose-rotation-with-transformation (transformation angle &optional
origin)
  (compose-transformations transformation (make-rotation-transformation
angle origin)))

(defun compose-transformation-with-translation (transformation dx dy)
  (compose-transformations (make-translation-transformation dx dy)
transformation))

(defun compose-transformation-with-scaling (transformation sx sy &optional
origin)
  (compose-transformations (make-scaling-transformation sx sy origin)
transformation))

(defun compose-transformation-with-rotation (transformation angle &optional
origin)
  (compose-transformations (make-rotation-transformation angle origin)
transformation))
)
;;;;




More information about the mcclim-devel mailing list