Страницы: 1
for(var i=0;this.points.length; i++)
:) thanks
[code]<html>
<head>
</head>
<body>
<canvas height="600" width="800" id="canvas" />
<script type="text/javascript">
function Point(x,y)
{
this.x = x;
this.y = y;
}
function Line(p1,p2)
{
this.p1 = p1;
this.p2 = p2;
this.length = Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); /////////error here********************
}
function Shape()
{
this.points = []; /////////////
this.lines = []; //////////////
this.init();
}
Shape.prototype = {
constructor:Shape,
init: function()
{
if(typeof this.context === 'undefined')
{
var canvas = document.getElementById('canvas');
Shape.prototype.context = canvas.getContext('2d');
}
},
draw: function()
{
var ctx = this.context;
ctx.strokeStyle = this.getColor();
ctx.beginPath();
ctx.moveTo(this.points[0].x, this.points[0].y);
for(var i=1; i<this.points.length; i++)
ctx.lineTo(this.points[i].x, this.points[i].y);
ctx.closePath();
ctx.stroke();
},
get
Страницы: 1