Canvas Stuff

Clifford Attractor

Clifford Attractor implemented in javascript with the canvas element. See here and Chaos Theory for more information.


A:
B:
C:
D:

Source:

	var x = 0.0;
        var y = 0.0;

        var a = 1.5;
        var b = -1.8;
        var c = 1.6;
        var d = 0.9;

	function animate(){
	        var canvas = document.getElementById("can");
		var context = canvas.getContext("2d");
	        context.fillStyle = "rgb(0,0,0)";
		for(var i = 0; i < 50; i++){ 
		        context.fillRect (300+x*100, 300+y*100, 1, 1);
		        
			var tmpX = Math.sin(a*y) + c*Math.cos(a*x);
			var tmpY = Math.sin(b*x) + d*Math.cos(b*y);

			x = tmpX;
			y = tmpY;
		}

	        setTimeout("animate();",100); 
	}
    

Home