From 099c3f927c11fe7ae4d12933d6f72abc0b53e973 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 30 Jun 2022 07:45:23 -0500 Subject: [modify] changed unit-width/height to just width/height. made defun --- examples/02-moving-bitmp.lisp | 10 +++++----- examples/03-font-render.lisp | 8 ++++---- src/core-units/affine.lisp | 14 ++++++-------- src/protocol.lisp | 5 ----- src/wheelwork.lisp | 2 +- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/examples/02-moving-bitmp.lisp b/examples/02-moving-bitmp.lisp index bb6ae8f..7cb03d3 100644 --- a/examples/02-moving-bitmp.lisp +++ b/examples/02-moving-bitmp.lisp @@ -19,7 +19,7 @@ (: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-w (incf (ww::width target) 20)) (:scancode-r (incf (ww::rotation target) (/ pi 3))) (:scancode-l (decf (ww::rotation target) (/ pi 3))) (:scancode-equals @@ -44,10 +44,10 @@ (dx 0) (dy 0)) (case scancode - (:scancode-down (setf dy -1 desty (- ty (ww::unit-height target)))) - (:scancode-up (setf dy 1 desty (+ ty (ww::unit-height target)))) - (:scancode-left (setf dx -1 destx (- tx (ww::unit-width target)))) - (:scancode-right (setf dx 1 destx (+ tx (ww::unit-width target))))) + (:scancode-down (setf dy -1 desty (- ty (ww::height target)))) + (:scancode-up (setf dy 1 desty (+ ty (ww::height target)))) + (:scancode-left (setf dx -1 destx (- tx (ww::width target)))) + (:scancode-right (setf dx 1 destx (+ tx (ww::width target))))) (ww::add-handler target (ww::on-perframe () diff --git a/examples/03-font-render.lisp b/examples/03-font-render.lisp index e36dc44..bdd1c6e 100644 --- a/examples/03-font-render.lisp +++ b/examples/03-font-render.lisp @@ -16,7 +16,7 @@ (format t "Pressed a key, changing the color~%") (setf (ww::text-color target) (random-text-color)) - (with-accessors ((x ww::x) (y ww::y) (w ww::unit-width) (h ww::unit-height)) target + (with-accessors ((x ww::x) (y ww::y) (w ww::width) (h ww::height)) target (format t "x:~a,y:~a,width:~a,height:~a~%" x y w h)))) (ww::defhandler marquee @@ -61,8 +61,8 @@ (ww::scale-by hello 3.0) (setf - (ww::x hello) (* 0.5 (- 800 (ww::unit-width hello))) - (ww::y hello) (* 0.5 (- 600 (ww::unit-height hello)))) + (ww::x hello) (* 0.5 (- 800 (ww::width hello))) + (ww::y hello) (* 0.5 (- 600 (ww::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::x instructions) (* 0.5 (- 800 (ww::unit-width instructions)))) + (ww::x instructions) (* 0.5 (- 800 (ww::width instructions)))) (ww::add-unit app instructions))) diff --git a/src/core-units/affine.lisp b/src/core-units/affine.lisp index e4db874..cabe17c 100644 --- a/src/core-units/affine.lisp +++ b/src/core-units/affine.lisp @@ -21,29 +21,27 @@ scale-y (* amount scale-y)))) (defun set-width-preserve-aspect (affine new-width) - (scale-by affine (/ new-width (unit-width affine)))) + (scale-by affine (/ new-width (width affine)))) (defun set-height-preserve-aspect (affine new-height) - (scale-by affine (/ new-height (unit-height affine) ))) + (scale-by affine (/ new-height (height affine) ))) -(defmethod unit-width ((affine affine)) +(defun width (affine) (with-slots (scale-x base-width) affine (* scale-x base-width))) -(defmethod unit-height ((affine affine)) +(defun height (affine) (with-slots (scale-y base-height) affine (* scale-y base-height))) -(defmethod (setf unit-width) (newval (affine affine)) +(defun (setf width) (newval affine) (with-slots (scale-x base-width) affine (setf scale-x (coerce (/ newval base-width) 'single-float)))) -(defmethod (setf unit-height) (newval (affine affine)) +(defun (setf height) (newval affine) (with-slots (scale-y base-height) affine (setf scale-y (coerce (/ newval base-height) 'single-float)))) - - (defmethod model-matrix :around ((u affine)) (or (cached-model u) (setf (cached-model u) diff --git a/src/protocol.lisp b/src/protocol.lisp index 24a34c2..f8386a6 100644 --- a/src/protocol.lisp +++ b/src/protocol.lisp @@ -23,11 +23,6 @@ (:documentation "Adds a unit to a container, removing it from its current container first, if necessary.")) -(defgeneric unit-width (unit)) -(defgeneric unit-height (unit)) -(defgeneric (setf unit-width) (newval unit)) -(defgeneric (setf unit-height) (newval unit)) - (defgeneric render (thing) (:documentation "Renders thing for visual display.")) diff --git a/src/wheelwork.lisp b/src/wheelwork.lisp index 885ae1e..849e2c7 100644 --- a/src/wheelwork.lisp +++ b/src/wheelwork.lisp @@ -66,7 +66,7 @@ TARGET is FOCUSABLEP" (defun get-rect (unit) "Returns a list of vectors representing the path of the smallest rectangle that encloses the unit. The rectangle is scaled and rotated." - (with-accessors ((x x) (y y) (w unit-width) (h unit-height) (r rotation)) unit + (with-accessors ((x x) (y y) (w width) (h height) (r rotation)) unit (let ((m (mat:meye 4)) (tr -- cgit v1.2.3