4)Square and Rectangle
<!DOCTYPE HTML>
<html>
<head>
<style>
#test {
width: 100px;
height:100px;
margin: 0px auto;
}
</style>
<script type = "text/javascript">
function drawShape() {
// Get the canvas element using the DOM
var canvas = [Link]('mycanvas');
// Make sure we don't execute when canvas isn't supported
if ([Link]) {
// use getContext to use the canvas for drawing
var ctx = [Link]('2d');
// Draw shapes
[Link] =”green";
[Link](20,10,100,100);
[Link](60,70);
[Link] =”blue";
[Link](10,30,140,80);
} else {
alert('You need Safari or Firefox 1.5+ to see this demo.');
}
}
</script>
</head>
<body id = "test" onload = "drawShape();">
<canvas id = "mycanvas"></canvas>
</body>
</html>
5) Bezier Curve
<!DOCTYPE HTML>
<html>
<head>
<style>
#test {
width: 100px;
height:100px;
margin: 0px auto;
}
</style>
<script type = "text/javascript">
function drawShape() {
// get the canvas element using the DOM
var canvas = [Link]('mycanvas');
// Make sure we don't execute when canvas isn't supported
if ([Link]) {
// use getContext to use the canvas for drawing
var ctx = [Link]('2d');
[Link]();
[Link](75,40);
[Link](75,37,70,25,50,25);
[Link](20,25,20,62.5,20,62.5);
[Link](20,80,40,102,75,120);
[Link](110,102,130,80,130,62.5);
[Link](130,62.5,130,25,100,25);
[Link](85,25,75,37,75,40);
[Link]();
} else {
alert('You need Safari or Firefox 1.5+ to see this demo.');
}
}
</script>
</head>
<body id = "test" onload = "drawShape();">
<canvas id = "mycanvas"></canvas>
</body>
</html>
6) Image
<html>
<head>
<script type = "text/javascript">
function drawShape() {
// get the canvas element using the DOM
var canvas = [Link]('mycanvas');
// Make sure we don't execute when canvas isn't supported
if ([Link]) {
// use getContext to use the canvas for drawing
var ctx = [Link]('2d');
// Draw shapes
var img = new Image();
[Link] = '/images/[Link]';
[Link] = function() {
[Link](img,0,0);
[Link]();
[Link](30,96);
[Link](70,66);
[Link](103,76);
[Link](170,15);
[Link]();
}
} else {
alert('You need Safari or Firefox 1.5+ to see this demo.');
}
}
</script>
</head>
<body onload = "drawShape();">
<canvas id = "mycanvas"></canvas>
</body>
</html>