Reimplement Pixi graphics init #5

Open
opened 2025-08-06 16:52:51 +00:00 by apt-get · 0 comments
Owner

Old code:

(ns miim.graphics.pixi
  (:require ["pixi.js" :as PIXI]
            [emptyhead.lib.io.print]
            [emptyhead.thought.crud :as thought]
            [emptyhead.thought.eval :as eval]
            [emptyhead.idea.protocol :as prtc]
            [emptyhead.thought.define :as def]))

(def/define!
  [:miim :graphics :make-screen]
  (fn [thought parent]
    (let [[parent args] (thought/pop-stack parent)
          app (PIXI/Application.)]
      (println args)
      (-> (.init app (clj->js args))
          (.then (fn [] (.appendChild js/document.body (.-canvas app)))))
      [parent app])))

(def populate
   (thought/register-thought!
    [:emptyhead :core :pure]
    :data {:height 256 :width 256 :background "29028F"}))

(def combined
  (let [operations [populate (thought/register-thought! [:miim :graphics :make-screen])]
        pure (eval/execute! (thought/register-thought! [:emptyhead :core :pure] :data operations))
        meme (eval/execute! (thought/make-thought [:emptyhead :core :sequence])
                            pure
                            )]
    (-> meme thought/pop-stack last)))

Old code: ```clojure (ns miim.graphics.pixi (:require ["pixi.js" :as PIXI] [emptyhead.lib.io.print] [emptyhead.thought.crud :as thought] [emptyhead.thought.eval :as eval] [emptyhead.idea.protocol :as prtc] [emptyhead.thought.define :as def])) (def/define! [:miim :graphics :make-screen] (fn [thought parent] (let [[parent args] (thought/pop-stack parent) app (PIXI/Application.)] (println args) (-> (.init app (clj->js args)) (.then (fn [] (.appendChild js/document.body (.-canvas app))))) [parent app]))) (def populate (thought/register-thought! [:emptyhead :core :pure] :data {:height 256 :width 256 :background "29028F"})) (def combined (let [operations [populate (thought/register-thought! [:miim :graphics :make-screen])] pure (eval/execute! (thought/register-thought! [:emptyhead :core :pure] :data operations)) meme (eval/execute! (thought/make-thought [:emptyhead :core :sequence]) pure )] (-> meme thought/pop-stack last))) ```
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: akko/nothoughts#5
No description provided.