Silly me. I was using the browse-repl URL instead of just going to localhost:3000 ... localhost:3000 does show the canvas!
Play time! ... Thanks Nikita! ,boz On Friday, January 17, 2014 8:06:34 AM UTC-8, Nikita Beloglazov wrote: > Did you require monet.canvas like this: (require '[monet.canvas :as canvas]) ? > > > > Anyway you can try use full namespace: > > > (def mc (monet.canvas/init (.getElementById js/document "canvas"))) > > > > > On Fri, Jan 17, 2014 at 3:54 PM, boz jennings <[email protected]> wrote: > > getElementById without the 0 compiles fine (thanks!) and I get no errors in > the repl console or the JS console ... yet the colored rectangle doesn't show > up. hmmm > > > > Seems like the canvas element isn't in the repl-ized window or something... > > > > cljs.user=> (def mc (canvas/init (.getElementById js/document "canvas"))) > > "Error evaluating:" (def mc (canvas/init (.getElementById js/document > "canvas"))) :as "cljs.user.mc = > canvas.init.call(null,document.getElementById(\"canvas\"));\n" > > > #<ReferenceError: canvas is not defined> > > ReferenceError: canvas is not defined > > at eval (eval at <anonymous> > (http://localhost:63402/560/repl/start:1463:318), <anonymous>:1:80) > > at eval (eval at <anonymous> > (http://localhost:63402/560/repl/start:1463:318), <anonymous>:5:3) > > at http://localhost:63402/560/repl/start:1463:313 > > at clojure.browser.repl.evaluate_javascript > (http://localhost:63402/560/repl/start:1464:338) > > at Object.callback (http://localhost:63402/560/repl/start:1472:82) > > at goog.messaging.AbstractChannel.deliver > (http://localhost:63402/560/repl/start:1340:393) > > at goog.net.xpc.CrossPageChannel.xpcDeliver > (http://localhost:63402/560/repl/start:1433:350) > > at Function.goog.net.xpc.NativeMessagingTransport.messageReceived_ > (http://localhost:63402/560/repl/start:1392:389) > > at goog.events.Listener.handleEvent > (http://localhost:63402/560/repl/start:1072:102) > > at Object.goog.events.fireListener > (http://localhost:63402/560/repl/start:1087:448) > > nil > > cljs.user=> > > > > Maybe I need to start with something simpler than cljs-start. I don't > understand all what it's doing yet. > > > > ,boz > > > > > On Friday, January 17, 2014 7:07:30 AM UTC-8, Nikita Beloglazov wrote: > > > I'd say feel free to use getElementById. But you don't need to pass 0 in > > this case. In former example (.get ... 0) was used to get actual dom > > element from array returned by JQuery. In your case you get dom element in > > the first place and don't need to get 0-st element. > > > > > > > > > > > > > > > > > > On Fri, Jan 17, 2014 at 2:59 PM, boz jennings <[email protected]> wrote: > > > > > > Thanks 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 > > > > > > > > > > > > > > > > > > On Thursday, January 16, 2014 5:42:53 AM UTC-8, Nikita Beloglazov wrote: > > > > > > > Hi 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 > > > > > > > > > > > > > > On Thursday, January 16, 2014 2:53:33 AM UTC, boz jennings wrote: > > > > > > > > Hi, > > > > > > > > > > > > > > > > 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! > > > > > > > > , > > > > > > > > > > > > -- > > > > > > 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 > > [email protected]. > > > > > > To post to this group, send email to [email protected]. > > > > > > > > Visit this group at http://groups.google.com/group/clojurescript. > > > > -- > > 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 > [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at http://groups.google.com/group/clojurescript. -- Note that posts from new members are moderated - please be patient with your first post. --- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
