Created
October 17, 2017 16:24
-
-
Save anonymous/40d0d392b1ea84713cddeafa3fd67789 to your computer and use it in GitHub Desktop.
react-fabricjs and CLJS
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 coverton.fabric.views | |
(:require [reagent.core :as r] | |
[react-fabricjs] | |
[taoensso.timbre :refer-macros [info]])) | |
(def Canvas window.fabric.Canvas) | |
(def Rect window.fabric.Rect) | |
(def Text window.fabric.Text) | |
(def img-url "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png") | |
(defn fabric [] | |
(let [canvas (r/atom nil)] | |
(r/create-class | |
{:component-did-mount | |
(fn [this] | |
(let [c (Canvas. "canv") | |
r (Rect. (clj->js {:left 50 :top 50 | |
:fill "red" :width 50 | |
:height 50}))] | |
(reset! canvas c) | |
(.add c r) | |
(.add c (Text. "Hello World" (clj->js {:left 100 :top 100}))))) | |
:reagent-render | |
(fn [] | |
[:div.editor | |
[:canvas#canv]])}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment