Chandan Prakash
classes
, let
/const
, arrow functions
, syntactical feature
from ES8. In the manipulation of canvases generated using p5.js - I required the use of React hooks and CSS, and I used the DOM manipulation features of JavaScript to interact with p5 sketches by wrapping it in a React component.React
is one of the most popular JavaScript libraries for creating single page applications.p5.js
is a JavaScript library with a full set of drawing functionality.TypeScript
is an open-source language which builds on JavaScript, one of the world’s most used tools, by adding static type definitions.performance
of the application, many latest React features have been used:MVVM
Model-View-ViewModel for all the components.There were total of seven commits which included adding artboard canvas with typescript support, p5 sketch in instance mode, etc.
prop
changes, the hooks automatically
updates itself and changes gets reflected in the p5 sketch (as it is passed as a dependency) too. Using this, a turtle
can draw arcs, lines,rotate at some degree,etc with a prop passed for each function.manager component
can handle multiple sketches and turtles. It generates unique ids for each artboard sketch and use it to differentiate between them while sending signals. It stores the ids in a array of list. It also establish communication between artbaord components with other components with the help of monitor component. It can add a new artboard(canvas), remove an existing artboard, renders a particular turtle to draw on artboard, etc. It receives signals
from monitor component to do a change in a particular artboard. It maintains a list of artboards which are currently present in the program.create
, remove
, update
artboards, etc.png
, svg
format.Just like p5 wrapper
we can also put the code for art board in a separate utility. Check here for more details.