In this tutorial, we will make an Object called drawing
that will contain the shapes.
The context for drawing the shapes is a HTML DOM element called a canvas
so that has to
form part of the drawing class along with a list of the objects that are being contained.
The object drawing
is a good example of the concept of composition
since it
is entirely made up of other objects.
Below, you can see the class drawing
that is used to create the "world" for the
shape
objects to reside in.
Make note of the following:
canvas
and objects
where
canvas
is a HTML DOM element and
objects
is a list
This is a development site to gather together teaching materials for AQA A Level Computer Science. It will be changing and being remodelled throughout this year.
No data is stored on the site but cookies are used to enable the website to function properly.
© 2025 Jay Patel - Dixons Sixth Form Academy, Bradford
Contact: jpatel@dixons6a.com