<!DOCTYPE html> <HTML> <BODY> <canvas id="canvas" width="640" height="480">Your browser does not support the HTML5 canvas tag.</canvas> <script> var c = document.getElementById("canvas"); var ctx = c.getContext("2d"); var imgData=ctx.getImageData(0,0,c.width,c.height); function rand(n) { return Math.floor((Math.random()*n)); } function drawPixel (x, y, r, g, b, a) { var index = (x + y * 640) * 4; imgData.data[index + 0] = r; imgData.data[index + 1] = g; imgData.data[index + 2] = b; imgData.data[index + 3] = a; } function updateCanvas() { ctx.putImageData(imgData, 0, 0); } function draw() { while (count<100) { count++; var choose=rand(100); if (choose<2) { x=0; y=0.16*y; } if (choose>=2 && choose<86) { x_new=0.85*x+0.04*y; y=-0.04*x+0.85*y+1.6; x=x_new; } if (choose>=86 && choose<93) { x_new=0.2*x-0.26*y; y=0.23*x+0.22*y+1.6; x=x_new; } if (choose>=93) { x_new=-0.15*x+0.28*y; y=0.26*x+0.25*y+0.44; x=x_new; } drawPixel(Math.floor((x+2.2)*100),Math.floor(y*48),0,0,0,255); } } var x=0; var y=0; var count; for (var j=0; j<500; j++) { count=0; draw(); updateCanvas(); } console.log("done"); </script> </BODY> </HTML>