CP1: Drawing Basics in P5JS – Width/Height Variables
Channel: Jeff Thompson
Date: 2020-09-03

Drawing shapes with set pixel values is ok, but if you want to your sketch to be resizable, it will be much better if everything your drawing commands aren't based on fixed values (also called "hard-coded") but instead are relative to the width/height of the canvas. We can do that with a little math and the built-in "width" and "height" variables, set by the createCanvas() command!


🖥 https://editor.p5js.org/jeffThompson/sketches/PN-1y2QdV

ALL THE VIDEOS IN THIS UNIT
🎥 https://www.youtube.com/playlist?list=PLsGCUnpinsDkQQXQwjgoAORziwqgleYaJ

CHALLENGES
❓ Can you re-write the code from the DrawingCommands example to be all relative to width/height?
❓ What other cool ways can you think of to make your sketch elements change size (or not change!) as the browser window is resized?