0

Kindly note the error which i made in my code :

<html>
<head>
<script type="text/javascript">
function createCanopyPath(context) {
// Draw the tree canopy
context.beginPath();
context.moveTo(-25, -50);
context.lineTo(-10, -80);
context.lineTo(-20, -80);
context.lineTo(-5, -110);
context.lineTo(-15, -110);
// Top of the tree
context.lineTo(0, -140);
context.lineTo(15, -110);
context.lineTo(5, -110);
context.lineTo(20, -80);
context.lineTo(10, -80);
context.lineTo(25, -50);
// Close the path back to its start point
context.closePath();
}
function drawTrails() {
var canvas = document.getElementById('trails');
var context = canvas.getContext('2d');
context.save();
context.translate(130, 250);
// Create the shape for our canopy path
createCanopyPath(context);
// Stroke the current path
context.stroke();
context.restore();
}
</script>
</head>
<body onload="drawTrails()">
   <canvas id="trials" style="border: 1px solid;" width="600" height="600"></canvas>
</body>
</html>
3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by lambing
0

getContext is available for html5 only. You should declare the doctype on top of your file.

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
    </body>
</html>

hope that works

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.