I have an html canvas and would like to display a Quil sketch on it. Most of the Quil examples use defsketch
to draw onto a canvas defined on a static html page. I would like to do it onto the canvas within this Reagent component:
(defn my-component []
(reagent/create-class
{:component-did-mount (fn [this]
(let [canvas (reagent/dom-node this)
width (.-width canvas)
height (.-height canvas)]
(u/log (str "On canvas with width, height: " width " " height))))
:component-will-mount #(u/log "component-will-mount")
:display-name "my-component"
:reagent-render (fn [] [:canvas {:width 400}])}))
(defn graph-panel []
[v-box
:gap "1em"
:children [[my-component]]])
The best documentation I've found for doing this sort of thing is here, but I can't quite work out how to go to the next level and apply it to the canvas above. Actual code for say drawing a line on the above canvas would be great.
In fact a static and always running defsketch
would be fine - the difficulty would be having it access this dynamic kind of canvas.
If it can't be done then that would be nice to know, and I'll use Processing.js directly, assuming that's the next best idea.