From e0fc8f0f7a8b4756226cfb5e1c7581e411420228 Mon Sep 17 00:00:00 2001
From: Colin Okay <colin@cicadas.surf>
Date: Thu, 30 Jun 2022 07:35:16 -0500
Subject: [refactor] factored out affine from unit; made container a unit;

---
 examples/02-moving-bitmp.lisp | 28 ++++++++++++++--------------
 examples/03-font-render.lisp  | 18 +++++++++---------
 2 files changed, 23 insertions(+), 23 deletions(-)

(limited to 'examples')

diff --git a/examples/02-moving-bitmp.lisp b/examples/02-moving-bitmp.lisp
index 3c9ee89..bb6ae8f 100644
--- a/examples/02-moving-bitmp.lisp
+++ b/examples/02-moving-bitmp.lisp
@@ -15,20 +15,20 @@
       "Move the target around, grow and shrink it. Print out its
        position no matter what happens."
       (case scancode
-        (:scancode-left (decf (ww::unit-x target) ))
-        (:scancode-right (incf (ww::unit-x target) ))
-        (:scancode-down (decf (ww::unit-y target) ))
-        (:scancode-up (incf (ww::unit-y target) ))
+        (:scancode-left (decf (ww::x target) ))
+        (:scancode-right (incf (ww::x target) ))
+        (:scancode-down (decf (ww::y target) ))
+        (:scancode-up (incf (ww::y target) ))
         (:scancode-w (incf (ww::unit-width target) 20))
-        (:scancode-r (incf (ww::unit-rotation target) (/ pi 3)))
-        (:scancode-l (decf (ww::unit-rotation target) (/ pi 3)))
+        (:scancode-r (incf (ww::rotation target) (/ pi 3)))
+        (:scancode-l (decf (ww::rotation target) (/ pi 3)))
         (:scancode-equals
          (when (or (member :lshift modifiers) (member :rshift modifiers))
            (ww::scale-by target 1.10)))
         (:scancode-minus
          (ww::scale-by target 0.9)))
       (format t "ghoul pos: ~a,~a~%"
-              (ww::unit-x target) (ww::unit-y target))))
+              (ww::x target) (ww::y target))))
 
 (ww::defhandler animate-move-thing
     (ww::on-keydown ()
@@ -37,8 +37,8 @@
       (when (member scancode '(:scancode-left :scancode-right :scancode-down :scancode-up)) 
         (unless (gethash target *shared-anim-table*)
           (setf (gethash target *shared-anim-table*) t)
-          (let* ((tx (ww::unit-x target))
-                 (ty (ww::unit-y target))
+          (let* ((tx (ww::x target))
+                 (ty (ww::y target))
                  (destx tx)
                  (desty ty)
                  (dx 0)
@@ -66,7 +66,7 @@
 
 (ww::defhandler flip-on-click
     (ww::on-mousedown ()
-      (incf (ww::unit-rotation target) (ww::radians 180) )))
+      (incf (ww::rotation target) (ww::radians 180) )))
 
 (ww::defhandler twirl-on-click
     (ww::on-mousedown ()
@@ -78,9 +78,9 @@
            (ww::on-perframe ()
              (if (< rot (* 8 pi))
                  (setf rot (+ 0.3 rot)
-                       (ww::unit-rotation target) rot)
+                       (ww::rotation target) rot)
                  (progn
-                   (setf (ww::unit-rotation target) 0.0)
+                   (setf (ww::rotation target) 0.0)
                    (ww::remove-handler target 'ww::perframe)
                    (remhash target *shared-anim-table*)))))))))
 
@@ -117,8 +117,8 @@
     (ww::add-handler bm #'mouse-over)
     
     ;;second
-    (setf (ww::unit-x bm2) 90
-          (ww::unit-y bm2) 90)
+    (setf (ww::x bm2) 90
+          (ww::y bm2) 90)
     (ww::add-handler bm2 #'move-thing)
     (ww::add-handler bm2 #'twirl-on-click )
     (ww::add-handler bm2 #'look-at-me)
diff --git a/examples/03-font-render.lisp b/examples/03-font-render.lisp
index 6f7d1a7..e36dc44 100644
--- a/examples/03-font-render.lisp
+++ b/examples/03-font-render.lisp
@@ -16,15 +16,15 @@
       (format t "Pressed a key, changing the color~%")
       (setf (ww::text-color target) (random-text-color))
 
-      (with-accessors ((x ww::unit-x) (y ww::unit-y) (w ww::unit-width) (h ww::unit-height)) target 
+      (with-accessors ((x ww::x) (y ww::y) (w ww::unit-width) (h ww::unit-height)) target 
         (format t "x:~a,y:~a,width:~a,height:~a~%" x y w h))))
 
 (ww::defhandler marquee
     (ww::on-perframe ()
-      (when (< 900 (ww::unit-x target))
-        (setf (ww::unit-x target)
+      (when (< 900 (ww::x target))
+        (setf (ww::x target)
               -800))
-      (incf (ww::unit-x target) 5 )))
+      (incf (ww::x target) 5 )))
 
 (defvar *spin-table* (make-hash-table :synchronized t))
 
@@ -36,9 +36,9 @@
             (setf
              (gethash target *spin-table*) (+ rot 0.88)
              (ww::text-color target) (random-text-color)
-             (ww::unit-rotation target) rot)
+             (ww::rotation target) rot)
             (progn
-              (setf (ww::unit-rotation target) 0.0) 
+              (setf (ww::rotation target) 0.0) 
               (ww::remove-handler target #'spin)
               (remhash target *spin-table*))))))
 
@@ -61,8 +61,8 @@
  
     (ww::scale-by  hello 3.0)
     (setf
-     (ww::unit-x hello) (* 0.5 (- 800 (ww::unit-width hello))) 
-     (ww::unit-y hello) (* 0.5 (- 600 (ww::unit-height hello))))
+     (ww::x hello) (* 0.5 (- 800 (ww::unit-width hello))) 
+     (ww::y hello) (* 0.5 (- 600 (ww::unit-height hello))))
     (ww::add-handler hello #'marquee)
     (ww::add-handler hello #'change-text-color)
     (ww::add-handler hello #'twirl-on-click)
@@ -71,7 +71,7 @@
 
     (ww::scale-by instructions 2.0)
     (setf
-     (ww::unit-x instructions) (* 0.5 (- 800 (ww::unit-width instructions))))
+     (ww::x instructions) (* 0.5 (- 800 (ww::unit-width instructions))))
     (ww::add-unit app instructions)))
 
 
-- 
cgit v1.2.3