Skip to content

Commit

Permalink
Merge pull request #139 from Norgat/master
Browse files Browse the repository at this point in the history
Add warning raise when user binds sketch to canvas with different graphics context.
  • Loading branch information
nbeloglazov committed Oct 10, 2014
2 parents d759034 + d863850 commit 2d52a2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject quil "2.2.2"
(defproject quil "2.2.3-SNAPSHOT"
:description "(mix Processing Clojure)"
:url "http://github.com/quil/quil"

Expand Down
14 changes: 8 additions & 6 deletions src/cljs/quil/sketch.cljs
Expand Up @@ -76,14 +76,16 @@
(set! (.-quil prc) (atom nil))
(set! (.-target-frame-rate prc) (atom 60)))))

(defn sketch
[& opts]
(defn sketch [& opts]
(let [opts-map (apply hash-map opts)
host-elem (dom/get-element (:host opts-map))
processing-fn (make-sketch opts-map)]
host-elem (.getElementById js/document (:host opts-map))
renderer (or (:renderer opts-map) :p2d)]
(when host-elem
(js/Processing. host-elem processing-fn))))

(if (.-processing-context host-elem)
(when-not (= renderer (.-processing-context host-elem))
(.warn js/console "WARNING: Using different context on one canvas!"))
(set! (.-processing-context host-elem) renderer))
(js/Processing. host-elem (make-sketch opts-map)))))

(def sketch-init-list (atom (list )))

Expand Down

0 comments on commit 2d52a2e

Please sign in to comment.