-
Book Overview & Buying
-
Table Of Contents
HTML5 Graphing and Data Visualization Cookbook
By :
I agree, we've been working on some complicated things. Now, its time for us to lay back, kick off the shoes, and do something a bit easier.
The good news is, if you are on this page, you should already know the basics of getting a canvas up and running. So there isn't much more that you need to do besides picking the font, size, and position of your text.
Here, we aren't covering how you can embed fonts that aren't created within JavaScript, but instead, via CSS, we will use a basic font and hope for the best in this sample.

In this example, we are going to create a text field. In this process, we are going to use gradients and shadows for the first time. Perform the following steps:
Gain access to the canvas 2D API:
var canvas = document.getElementById("textCanvas");
var wid = canvas.width;
var hei = canvas.height;
var context = canvas.getContext("2d");Create a gradient style and fill the background with it:
var grd = context.createLinearGradient...
Change the font size
Change margin width
Change background colour