Code skill Creating Graphics

This piece of code uses the <canvas> element to create a canvas on-screen, which you can then draw on using the getContext method. Use <input> tags and the onclick attribute to call a draw and remove function. In the finished code, you can click on a ‘Draw’ button to make a square appear, and a ‘Clear’ button to make it vanish.

See the Pen CS1 GB2 by Walker Books UK (@walkerbooks) on CodePen.