gibney.org
:
Technology
:
Javascript
:
Experiments
:
mandelbrot with controlled distortions
(Entry Nr. 2103, by user 1 |
edit
)
Mandelbrot with controlled distortions<br> <canvas id=canvas width=300 height=300 style='border: 1px solid #ff0000'></canvas> <br> <script> function iteration(ncx,ncy) { cx=ncx; cy=ncy; var bq = 0; var i = 0; var x = 0; var y = 0; var px = 0; var py = 0; while ( bq < 4 && i < 25 ) { var xt = x * x - y * y + cx; var yt = 2 * x * y + cy; sx=0.5; sy=0.1; dx=xt-sx; dy=yt-sy; dist=dx*dx+dy*dy px+=0.05*dx/dist; py+=0.05*dy/dist; x = xt+px; y = yt+px; i++; bq = x * x + y * y; } return i; } drawLine = function() { for (var y=1;y<300;y+=1) { var i = 10*iteration (this.x/100-2.2,y/100-1.5); this.ctx.fillStyle = "rgb("+i+", "+i+", "+i+")"; this.ctx.fillRect (this.x,y,1,1); } this.x++; if (this.x<300) setTimeout("drawLine()",10); } draw = function() { this.canvas = document.getElementById("canvas"); this.ctx = this.canvas.getContext("2d"); this.ctx.fillStyle = "rgb(0, 0, 100)"; this.x=1; this.drawLine(); } draw(); </script>
Create a new entry at this position