20.11.2017 Views

My HTML 5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>HTML</strong>5<br />

5<br />

strokeText(text, x, y [, maxWidth ] )<br />

This property strokes the given text at the given position indicated by the<br />

given coordinates x and y.<br />

Example<br />

Following is a simple example which makes use of above mentioned attributes to draw a<br />

text −<br />

<br />

<br />

<br />

<br />

#test {<br />

width: 100px;<br />

height:100px;<br />

margin: 0px auto;<br />

}<br />

<br />

<br />

function drawShape(){<br />

// get the canvas element using the DOM<br />

var canvas = document.getElementById('mycanvas');<br />

// Make sure we don't execute when canvas isn't supported<br />

if (canvas.getContext){<br />

// use getContext to use the canvas for drawing<br />

var ctx = canvas.getContext('2d');<br />

ctx.fillStyle<br />

ctx.font<br />

= '#00F';<br />

= 'Italic 30px Sans-Serif';<br />

92

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!