Created
May 24, 2015 21:11
-
-
Save nvbn/2fb29382674e18eb9b76 to your computer and use it in GitHub Desktop.
svg-image-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns svg-image-example.core | |
(:require [om.core :as om :include-macros true] | |
[om.dom :as dom])) | |
(defn image | |
[{:keys [href x y width height]} _] | |
(reify | |
om/IRender | |
(render [_] | |
(let [html (str "<image x='" x "' y='" y "'" | |
"width='" width "' height='" height "'" | |
"xlink:href='" href "'/>")] | |
(dom/g #js {:dangerouslySetInnerHTML #js {:__html html}}))))) | |
(defn scene | |
[_ _] | |
(reify | |
om/IRender | |
(render [_] | |
(dom/svg #js {:width 150 | |
:height 150} | |
(om/build image {:href "http://clojure.org/space/showimage/clojure-icon.gif" | |
:x 5 | |
:y 5 | |
:width 100 | |
:height 100}))))) | |
(om/root scene {} {:target (.getElementById js/document "main")}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<div id="main"></div> | |
<script src="result.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment