Online Book Reader

Home Category

HTML5 Canvas [46]

By Root 6495 0


Text Baseline


Text Align


Alpha: min="0.0"

max="1.0"

step="0.01"

value="1.0"/>


Shadow X:min="−100"

max="100"

step="1"

value="1"/>


Shadow Y:min="−100"

max="100"

step="1"

value="1"/>


Shadow Blur: min="1"

max="100"

step="1"

value="1" />


Shadow Color:


Canvas Width: min="0"

max="1000"

step="1"

value="500"/>


Canvas Height:

min="0"

max="1000"

step="1"

value="300"/>


Canvas Style Width: min="0"

max="1000"

step="1"

value="500"/>


Canvas Style Height:

min="0"

max="1000"

step="1"

value="300"/>




What’s Next

In this chapter, we introduced you to the fundamentals of the HTML5 Canvas Text API, offered some general concepts relating to drawing on the canvas, and explained how to communicate with HTML form controls. As you can now see, the basic concept of writing text to HTML5 Canvas can be taken to very complex (and some might argue ludicrous) levels. The final application, Text Arranger 3.0, allows you to modify a single line of text in an almost infinite number of ways. In the next chapter, we move on to displaying and manipulating images on the canvas.

Chapter 4. Images on the Canvas

Like the Canvas Drawing API, the Canvas Image API is very robust. With it, we can load in image data and apply it directly to the canvas. This image data can also be cut and spliced to display any desired portion. Furthermore, Canvas gives us the ability to store arrays of pixel data that we can manipulate and then draw back to the canvas.

There are two primary Canvas functions we can perform with images. We can display images, and we can modify them pixel by pixel and paint them back to the canvas. There are only a few Image API functions, but they open up a world of pixel-level manipulation that gives the developer the power to create optimized applications directly in the web browser without needing any plug-ins.

The Basic File Setup for This Chapter


All the examples in this chapter will use the same basic file setup for displaying our demonstrations as we proceed through the Drawing API. Use the following as the basis for all the examples we create—you will only need to change the contents of the drawScreen() function:

Ch4BaseFile - Template For Chapter 4 Examples