5.7 Embedding Images 135
Figure 5.20 “fillText()”, “strokeText()”, and “measureText()”
It is not currently possible to determine the height and origin point of the bound-
ing box, but this may be implemented in a future version of the specification,
together with multiline text layout. The final note in the text chapter of the Can-
vas specification sounds promising: It indicates that in the future, fragments of
documents (e.g., formatted paragraphs) might also find their way into Canvas
via CSS.
The Canvas API offers a multitude of options for working in Canvas with raster-
based formats not only in the future, but right now. In addition to embedding
images and videos, you also have optional reading and writing access to every
pixel on the canvas area. You can read up on how to do this in section 5.8, Pixel
Manipulation.
5.7 Embedding Images
For embedding images, Canvas offers the method drawImage(),which we can in-
voke with three different parameter sets (the method can take three, five, or nine
arguments):