;;; -*- lexical-binding: t -*- ;; ;; -------------------------------------------------------------------------- (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'luki-lisp) ;; -------------------------------------------------------------------------- (-> 'bad-borderless) (-> 'bad-color) (-> 'bad-write) ;; -------------------------------------------------------------------------- (defclass solid (borderless) ((name :initform (@f "solid-%d" (random 100))) (fg :initform (seq-random-elt (bad-fg-colors))) (spc :initform '(?#)) (w :initform #1=3) (h :initform #1#) (w-min :initform #1#) (h-min :initform #1#))) ;; -------------------------------------------------------------------------- (defclass triangle (solid) ((name :initform (@f "triangle-%d" (random 100))))) ;; -------------------------------------------------------------------------- (cl-defmethod bad-update ((tri triangle) &optional init) (when init (~ (w h data len spc) tri (setf data (cl-loop for l from 0 to #1=(1- h) for c from w downto 1 for p from 0 to #1# collect (concat (make-list c (1st spc)) (make-list p bad-nonsolid)) into res finally return (string-to-list (string-join res)))) (setf len (--- data))))) ;; -------------------------------------------------------------------------- (cl-defmethod bad-size :after ((tri triangle) &rest _) (~ (w h) tri (setf h w)) (bad-update tri t)) ;; -------------------------------------------------------------------------- (cl-defmethod bad-add ((b box) (tri triangle)) (~ (w h sub) b (~ ((iw w) (ih h) w-max h-max x y min-x min-y) tri (setf iw #1=3) (setf ih #1#) (setf w-max (- w 2)) (setf h-max (- h 2)) (setf x #3=1) (setf y #4=1) (setf min-x #3#) (setf min-y #4#)) (bad-update tri t) (push tri sub))) ;; -------------------------------------------------------------------------- (<- 'bad-triangle)