正在加载图片...
3、用直线连接圆 function drawLine(ctx,x,y,x2,y2,thickness){ ctx.beginPath(); function Line(start,end,thick) ctx.moveTo(x,y); this.startPoint start; ctx.lineTo(x2,y2); this.endPoint end; ctx.lineWidth thickness; this.thickness thick; ctx.strokeStyle ="#cfc"; ctx.stroke(); for(var i=0;i<untangleGame.circles.length;i++){ var startPoint untangleGame.circles[i]; for (var j=0;j<i;j++) var endPoint untangleGame.circles[i]; drawLine(ctx,startPoint.x,startPoint.y,endPoint.x,endPoint.y, 1 untangleGame.lines.push(new Line(startPoint,endPoint, untangleGame.thinLineThickness)); }3、用直线连接圆 for (var i = 0; i < untangleGame.circles.length; i++) { var startPoint = untangleGame.circles[i]; for (var j=0; j < i; j++){ var endPoint = untangleGame.circles[j]; drawLine(ctx, startPoint.x, startPoint.y, endPoint.x, endPoint.y, 1); untangleGame.lines.push(new Line(startPoint, endPoint, untangleGame.thinLineThickness)); } }; function drawLine(ctx, x, y, x2, y2, thickness){ ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x2, y2); ctx.lineWidth = thickness; ctx.strokeStyle = "#cfc"; ctx.stroke(); } function Line(start, end, thick){ this.startPoint = start; this.endPoint = end; this.thickness = thick; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有