Can someone give me pointers on using monet?
I'm trying to get to know Clojurescript. Just cloned cljs-start and put in dependencies and changes that I hope will work for monet https://github.com/rm-hull/monet
But I get this when compiling
WARNING: Wrong number of args (2) passed to monet.canvas/add-entity at line 17 /Users/boz/dev/clojure/cljs-start-001/src/cljs/cljs_start_001/core.cljs
Here's the code in cljs_start_001/core.cljs. It's basically just a copy from the monet README.md...
(ns cljs-start-001.core
(:require [monet.canvas :as canvas]))
(canvas/add-entity :background
(canvas/entity {:x 0 :y 0 :w 600 :h 600}
nil ;;update function
(fn [ctx box]
(-> ctx
(canvas/fill-style "#191d21")
(canvas/rect box)))))
(canvas/init (.get ($ :#canvas) 0))
monet's add-entity looks like this....
(defn add-entity [mc k ent]
(aset (:entities mc) k ent))
But I have no idea what mc k and ent are supposed to be.
Thanks!
,boz
I believe that mc stands for 'monet-canvas' which is created by 'init' function and example from README is incorrect. You need to get monet-canvas first from 'init' function and then add entity to it. Try this:
(def mc (canvas/init (.get ($ :#canvas) 0)))
(canvas/add-entity mc :background
(canvas/entity {:x 0 :y 0 :w 600 :h 600}
nil ;;update function
(fn [ctx box]
(-> ctx
(canvas/fill-style "#191d21")
(canvas/rect box)))))
Nikita
That helps. Now I read the monet code again and see mc all over the place :)
Wasn't able to get it working with the cljs-start yet. Haven't had much time to do it. Hopefully do more today.
Looks like the monet docs assume jayq is used too (that $). Does monet have a jayq dependency? Or is it OK to use this?
(def mc (canvas/init (.getElementById js/document "canvas") 0))
,boz
--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/fnf33iMsFdY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.