Rectangles
As well as the three techniques we saw in Drawing rectangles, which draw rectangular forms straight to the canvas, there is also the rect() technique, which adds a rectangular road to a path that is currently open.
rect(x, y, width, height) attracts a rectangle whose corner that is top-left specified by ( x , y ) using the specified width and height .
Before this process is performed, the moveTo() technique is immediately called with all the parameters (x,y). The current pen position is automatically reset to the default coordinates in other words.
Making combinations
Up to now, each instance with this web page has utilized just one form of path function per form. Nevertheless, there isn’t any limitation towards the true quantity or forms of paths you should use to produce a form. Therefore in this last instance, let us combine most of the path functions to help make a collection of really famous game figures.
The ensuing image appears such as this:
We will not look at this at length, as it’s really interestingly easy. Fortsätt läsa ”Drawing forms with canvas. Jump to part”