I have the following code, meant to represent a set of devices as SVG:
(ns foo.core
(:use [c2.core :only [unify]]
[c2.dom :only [replace! append!]]
[c2.svg :only [translate]]))
(def conf
{ :devices [{:alias "OSC Sender",
:name "OSC Sender",
:ins []},
{:alias "const2", :name "const",
:outs []}],
:layout [{:alias "const2",
:x 72.12447405329594,
:y 99.88499298737729},
{:alias "tick",
:x 82.5732819074334,
:y 133.91374474053296},
{:alias "OSC Sender",
:x 185.17741935483872,
:y 113.90322580645162}]})
(def render-config
[:svg {:viewBox "0 0 900 400"}
[:rect {:id "frame" :x "1" :y "1" :width "600" :height "300" :fill "none" :stroke "blue"}]
(unify (:layout conf)
(fn [{alias :alias x :x y :y}]
[:g {:transform (translate [x y])}
[:text alias]]))])
(append! "#main" render-config)
Trying to evaluate render-config
in the REPL, I get:
[:svg {:viewBox "0 0 900 400"} [:rect {:width "600", :y "1", :x "1", :fill "none", :stroke "blue", :id "frame", :height "300"}] ([:g {:transform "translate(72,99)"} [:text "const2"]] [:g {:transform "translate(82,133)"} [:text "tick"]] [:g {:transform "translate(185,113)"} [:text "OSC Sender"]])]
which looks like a proper Hiccup representation to me (certainly unify
did its magic).
Yet when evaluating render-config
in the context of a web page (using singult
), I only get an error. Generating a very simple SVG (basically only the enclosing "frame" rectangle) works in the browser.
Any hints/tips?
Cheers!
Note: rendering render-config
using Hiccup
, then spitting out the results in a file gives a SVG image that is readable by Inkscape.
--
You received this message because you are subscribed to the Google Groups "C2-cljs" group.
To unsubscribe from this group, send email to c2-cljs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I did not entirely grok your answer though; are the semantics of unify explained somewhere?