A complex canvas example

In the previous post we saw about canvas using path and also using rectangles in this example we will see how to combine them to form a complex and at the same time an interesting composition.

In the above example, we can find two methods drawbowtie and dot both these methods are called 4 times each. And the calls like translate(), rotate() are used to set transformation matrix which in turn positions the dot and the bowtie .dot function is used to place the small black square at (0,0). That dot is moved around by the transformation matrix .drawBowtie will create a very simple bowtie path using the passed-in fill style.
The functions save() and restore() are used to set the original canvas state.This rotation always occur around the current origin.Thus a translate() rotate() translate() sequence will yield different results than a translate() translate() rotate() series of calls.