@@ -1636,66 +1636,67 @@ socket.addEventListener('message', function(event) {
16361636| strokeText()| Draws text on the canvas (no fill) |
16371637| measureText()| Returns an object that contains the width of the specified text |
16381638
1639- ``` html
1640- <!DOCTYPE html>
1641- <html >
1642- <head >
1643- <title >HTML5 Canvas</title >
1644- </head >
1645- <body >
1646-
1647- <div ><b >Text</b ></div >
1648- <canvas id =" text" width =" 200" height =" 100" ></canvas ><br /><br />
1649-
1650-
1651- <div ><b >Straight Line</b ></div >
1652- <canvas id =" line" width =" 300" height =" 0" style =" border : 1px solid #333 ;" ></canvas ><br /><br />
1653-
1654-
1655- <div ><b >Rectangle</b ></div >
1656- <canvas id =" rectangle" width =" 300" height =" 200" style =" border : 1px solid #999 ;" ></canvas ><br /><br />
1639+ ** Example 01:** HTML5 Canvas for Text
16571640
1641+ ``` html
1642+ <div >Text</div >
1643+ <canvas id =" text" width =" 200" height =" 100" ></canvas >
16581644
1659- <div ><b >Rectangle with Style</b ></div >
1660- <canvas id =" rect" >This browser does not support Canvas!</canvas ><br /><br />
1645+ <script type =" text/javascript" >
1646+ // Text with style
1647+ var canvas = document .getElementById (' text' );
1648+ var context = canvas .getContext (' 2d' );
1649+ context .font = ' 20pt Calibri' ;
1650+ context .fillStyle = ' blue' ;
1651+ context .fillText (' Hello World!' , 50 , 50 );
1652+ </script >
1653+ ```
16611654
1655+ ** Example 02:** HTML5 Canvas for Straight Line
16621656
1663- <div ><b >Circle</b ></div >
1664- <canvas id =" circle" >This browser does not support Canvas!</canvas ><br /><br />
1657+ ``` html
1658+ <div >Straight Line</div >
1659+ <canvas id =" line" width =" 300" height =" 0" style =" border : 1px solid #333 ;" ></canvas >
16651660
1661+ <script type =" text/javascript" >
1662+ // Straight Line
1663+ var canvas = document .getElementById (" line" );
1664+ var context = canvas .getContext (" 2d" );
1665+ context .moveTo (50 , 150 );
1666+ context .lineTo (250 , 50 );
1667+ context .stroke ();
1668+ </script >
1669+ ```
16661670
1667- <script type =" text/javascript" >
1668- // Text with style
1669- var canvas = document .getElementById (' text' );
1670- var context = canvas .getContext (' 2d' );
1671- context .font = ' 20pt Calibri' ;
1672- context .fillStyle = ' blue' ;
1673- context .fillText (' Hello World!' , 50 , 50 );
1671+ ** Example 03:** HTML5 Canvas for Rectangle
16741672
1673+ ``` html
1674+ <div >Rectangle with Style</div >
1675+ <canvas id =" rect" >This browser does not support Canvas!</canvas >
16751676
1676- // Straight Line
1677- var canvas = document .getElementById (" line" );
1678- var context = canvas .getContext (" 2d" );
1679- context .moveTo (50 , 150 );
1680- context .lineTo (250 , 50 );
1681- context .stroke ();
1677+ <script type =" text/javascript" >
1678+ // Rectange with style
1679+ var canvas = document .getElementById (" rect" );
1680+ var context = canvas .getContext (" 2d" );
1681+ context .fillStyle = " #FF0000" ;
1682+ context .fillRect (0 , 0 , 300 , 200 );
1683+ </script >
1684+ ```
16821685
1686+ ** Example 04:** HTML5 Canvas for Circle
16831687
1684- // Rectange with style
1685- var canvas = document .getElementById (" rect" );
1686- var context = canvas .getContext (" 2d" );
1687- context .fillStyle = " #FF0000" ;
1688- context .fillRect (0 , 0 , 300 , 200 );
1688+ ``` html
1689+ <div >Circle</div >
1690+ <canvas id =" circle" >This browser does not support Canvas!</canvas >
16891691
1690- // Circle
1691- var canvas = document .getElementById (" circle" );
1692- var context = canvas .getContext (" 2d" );
1693- context .beginPath ();
1694- context .arc (95 , 50 , 40 , 0 , 2 * Math .PI );
1695- context .stroke ();
1696- </script >
1697- </body >
1698- </html >
1692+ <script type =" text/javascript" >
1693+ // Circle
1694+ var canvas = document .getElementById (" circle" );
1695+ var context = canvas .getContext (" 2d" );
1696+ context .beginPath ();
1697+ context .arc (95 , 50 , 40 , 0 , 2 * Math .PI );
1698+ context .stroke ();
1699+ </script >
16991700```
17001701
17011702<div align =" right " >
0 commit comments