<script src="http://spelprogrammering.nu/simple.js">
function start()
{
  var xStart = -1.55;
  var xEnd   = 1.55;
  var yStart = -0.9;
  var yEnd   = 0.9;

  var maxIteration = 1000;
  var c_re = -0.8;
  var c_im = 0.156;

  for (var x = 0; x < totalWidth; x++)
  {
    for (var y = 0; y < totalHeight; y++)
    {
      var re = ((x/totalWidth)*(xEnd-xStart))+xStart;
      var im = ((y/totalHeight)*(yEnd-yStart))+yStart;

      var iteration = 0;
      while (((re*re + im*im) < 4) && (iteration < maxIteration))
      {
        var oldRe = re;
        var oldIm = im;
        re = oldRe * oldRe - oldIm * oldIm + c_re;
        im = 2 * oldRe * oldIm + c_im;
        iteration++;
      }

      if (iteration == maxIteration)
        color = "black";
      else
        color = mixColor(255-iteration%155, 
                         255-iteration%195, 
                         255-iteration%255);

      rectangle(x, y, 1, 1, color);
    }
  }
}
</script>
        
Gå tillbaka