Issue
I need to know how to draw polygons on a canvas. Without using jQuery or anything like that.
Solution
Create a path with moveTo
and lineTo
(live demo):
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#f00';
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(100,50);
ctx.lineTo(50, 100);
ctx.lineTo(0, 90);
ctx.closePath();
ctx.fill();
Answered By - phihag
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.