(ns buddho.dhamma.graphics
  (:require [buddho.core.meta :as meta]
            [buddho.core.dhamma :as d]
            [buddho.core.graphics :as g]))

(defn create-sprite! []
  (d/register-dhamma! :create-sprite :transient nil))

;;; TODO render to actual screen
(defmethod d/impl! :create-sprite [_dhamma & [whole]]
  (let [url (-> whole :data :sprite-url)
        sprite (g/make-sprite! url)]
    (d/assoc-data whole :sprite sprite)))

(meta/register-meta! :create-sprite
                     :singleton-fn create-sprite!)
