;;; -*- lexical-binding: t -*- ;; -------------------------------------------------------------------------- (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'luki-lisp) ;; -------------------------------------------------------------------------- (-> 'bad-elem) (-> 'bad-move) (-> 'bad-pos) ;; -------------------------------------------------------------------------- (cl-defmethod bad-align-center-sub ((e elem) (dx integer) (dy integer)) (~ (w h sub) e (dolist (sub-e sub) (~ (x y align-center) sub-e (when align-center (let* ((do-x (z (m w 2))) (do-y (z (m h 2))) (hdx (+ (/ dx 2) (or (& (if (< 0 dx) do-x (! do-x)) (% dx 2)) 0))) (hdy (+ (/ dy 2) (or (& (if (< 0 dy) (! do-y) do-y) (% dy 2)) 0)))) (bad-mov sub-e hdx hdy))))))) ;; -------------------------------------------------------------------------- (cl-defmethod bad-align-rel-xy-sub ((e elem)) (~ (w h sub) e (dolist (sub-e sub) (~ (x y align-rel-xy) sub-e (when align-rel-xy (pcase-let* ((`(,px ,py) align-rel-xy)) (bad-pos sub-e (or (& px (+ w px)) x) (or (& py (+ h py)) y)))))))) ;; -------------------------------------------------------------------------- (cl-defmethod bad-align-sub ((e elem) (dx integer) (dy integer)) (bad-align-center-sub e dx dy) (bad-align-rel-xy-sub e)) ;; -------------------------------------------------------------------------- (<- 'bad-align)