Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defclass box ()
- ((location :accessor location :initarg :location :initform (vector 0 0))
- (dimensions :accessor dimensions :initarg :dimensions :initform (vector 1 1))))
- (defmethod x ((b box))
- (aref (location b) 0))
- (defmethod y ((b box))
- (aref (location b) 1))
- (defmethod (setf x) (new-val (b box))
- (setf (aref (location b) 0) new-value))
- (defmethod (setf y) (new-val (b box))
- (setf (aref (location b) 1) new-value))
- (defmethod width ((b box))
- (aref (dimensions b) 0))
- (defmethod height ((b box))
- (aref (dimensions b) 1))
- (defmethod (setf width) (new-val (b box))
- (setf (aref (dimensions b) 0)
- new-val))
- (defmethod (setf height) (new-val (b box))
- (setf (aref (dimensions b) 1)
- new-val))
- (defmethod (setf half-width) (new-val (b box))
- (setf (width b) (* new-val 2.0)))
- (defmethod (setf half-height) (new-val (b box))
- (setf (height b) (* new-val 2.0)))
- (defmethod half-width ((b box))
- (* (width b) .5))
- (defmethod half-height ((b box))
- (* (height b) .5))
- ;;; Edge Positions
- ;; SETFing an edge does not change dimension, rather it repositions the box
- (defmethod left ((b box))
- (- (x b)
- (half-width b)))
- (defmethod (setf left) (new-val (b box))
- (setf (x b)
- (+ (half-width b) new-val)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement