~lthms/fairy.lisp

09f96cf085926197546551364513b951d40827fa — Thomas Letan 4 years ago 56ce5a7
feature: A new element for printing text
1 files changed, 24 insertions(+), 3 deletions(-)

M fairy.lisp
M fairy.lisp => fairy.lisp +24 -3
@@ 20,22 20,30 @@
  (:export draw
           defdraw
           update

           element
           origin
           goto
           scale
           visible

           rectangle
           width
           height

           layer
           boundary
           add-child
           get-child
           delete-child
           delete-child-with-key

           image
           key))
           key

           text
           value
           font))

(cl:in-package :fairy)



@@ 161,8 169,21 @@

(defclass image (fairy:element)
  ((key :initarg :key
       :initform (error "must supply a resource key")
       :accessor key)))
        :initform (error "must supply a resource key")
        :accessor key)))

(defdraw (el image)
    (gamekit:draw-image (gamekit:vec2 0 0) (key el)))

(defclass text (fairy:element)
  ((value :initarg :value
          :initform ""
          :accessor value)
   (font :initarg :font
         :initform nil
         :accessor font)))

(defdraw (el text)
    (if (font el)
        (gamekit:draw-text (value el) (gamekit:vec2 0 0) :font (font el))
        (gamekit:draw-text (value el) (gamekit:vec2 0 0))))