After installing canvas-sketch globally, create a new folder to hold your sketch:
mkdir my-sketch
cd my-sketch
Now run the following to generate a new default .ts
file, package.json
, etc:
canvas-sketch sketch.ts --new
Once the server is running, kill it (Ctrl + C) and run the following to grab TypeScript, plugin and Node.js definitions:
npm install typescript tsify @types/node --save-dev
Now, overwrite the default file with the full sketch.ts
code in this gist. If you copy the code to clipboard you can run the following:
pbpaste > sketch.ts
Now you can run canvas-sketch again, but make sure to specify the tsify plugin like so, after a 'full stop' flag (--
) which will pass down any additional browserify transforms/plugins.
canvas-sketch sketch.ts --open -- -p [ tsify --noImplicitAny ]
Congrats! Now you are using TypeScript with canvas-sketch
.
hey @mattdesl, I get this error in windows