CGPL Lecture3
CGPL Lecture3
COMPUTER
GRAPHICS
PROGRAMMING
Introduction to HTML5 Canvas
01
SIMPLE CANVAS
TRANSFORMATION
SIMPLE CANVAS TRANSFORMATION
● Transformations on the canvas refer to the mathematical
adjustment of physical prop‐ erties of drawn shapes. The two
most commonly used shape transformations are scale and rotate.
● An object on the canvas is said to be at the 0 angle rotation when
it is facing to the left.
● Consequently, if we draw an equilateral box (all four sides are the
same length), it doesn’t have an initial facing side other than one
of the flat sides facing to the left. Let’s draw that box for
reference:
SIMPLE CANVAS TRANSFORMATION
● Now, if we want to rotate the entire canvas 45 degrees, we need
to do a couple simple steps. First, we always set the current
Canvas transformation to the “identity” (or “reset”) matrix: