Linescapes Iteration 3

Make it 3D.

[php lang=”JavaScript”]$(function() {
var canvas, context, width, height, x1, x2, y, z = 600, fl = 350, xcenter, ycenter, scale;

canvas = $(“#canvas”).get(0);
context = canvas.getContext(“2d”);
width = canvas.width;
height = canvas.height;
xcenter = width / 2;
ycenter = height / 2;

while(z > 0) {
scale = fl / (fl + z);
context.beginPath();
x1 = xcenter – width / 2 * scale;
x2 = xcenter + width / 2 * scale;
y = ycenter + 200 * scale;
context.moveTo(x1, y);
context.lineTo(x2, y);
context.stroke();
z -= 5;
}
});[/php]

Result.

This entry was posted in JavaScript. Bookmark the permalink.

Leave a Reply