Skip to content

Instantly share code, notes, and snippets.

Created October 17, 2017 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/40d0d392b1ea84713cddeafa3fd67789 to your computer and use it in GitHub Desktop.
Save anonymous/40d0d392b1ea84713cddeafa3fd67789 to your computer and use it in GitHub Desktop.
react-fabricjs and CLJS
(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