Renamed mandelbrot experiment.
authorEugen Sawin <sawine@me73.com>
Fri, 06 Jan 2012 00:02:26 +0100
changeset 83228adcfd8f23
parent 82 cb8897d7f508
child 84 b7834ce141c4
Renamed mandelbrot experiment.
experiments.html
factory/create_page
factory/v2012/experiments.html
factory/v2012/mandelbrot.html
factory/v2012/script.js
mandelbrot.html
script.js
     1.1 --- a/experiments.html	Thu Jan 05 23:29:27 2012 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,85 +0,0 @@
     1.4 -<!DOCTYPE html>
     1.5 -<html lang="en">
     1.6 -  <head>
     1.7 -    <title>ME73</title>
     1.8 -    <meta name="author" content="Eugen Sawin <sawine@me73.com>" />
     1.9 -    <meta name="description" content="A Digital Playground" />
    1.10 -    <meta name="robots" content="index, follow, noarchive" />
    1.11 -    <meta name="googlebot" content="noarchive" />
    1.12 -    <script src="jquery.js"></script>
    1.13 -    <script src="script.js"></script>
    1.14 -    <link rel="stylesheet" href="dark.css" type="text/css" />
    1.15 -    <script type="application/javascript">
    1.16 -      var _gaq = _gaq || [];
    1.17 -      _gaq.push(['_setAccount', 'UA-2137333-1']);
    1.18 -      _gaq.push(['_trackPageview']);
    1.19 -      (function() {
    1.20 -      var ga = document.createElement('script'); ga.type = 'text/javascript';
    1.21 -      ga.async = true;
    1.22 -      ga.src = ('https:' == document.location.protocol ? 'https://ssl' :'http://www') 
    1.23 -      + '.google-analytics.com/ga.js';
    1.24 -      var s = document.getElementsByTagName('script')[0];
    1.25 -      s.parentNode.insertBefore(ga, s);
    1.26 -      })();
    1.27 -    </script>
    1.28 -  </head>
    1.29 -  <body>
    1.30 -    <div id="wrap">
    1.31 -      <div id="header">
    1.32 -        <canvas id="logo">
    1.33 -          FIND A BETTER BROWSER
    1.34 -        </canvas>
    1.35 -        <canvas id="sim">
    1.36 -        </canvas>
    1.37 -      </div>
    1.38 -      <div id="content-wrap">
    1.39 -        <div id="main">
    1.40 -          <p>
    1.41 -<!--<img src="images/world.png" alt="world map" height="280" width="100%" />
    1.42 --->
    1.43 -<canvas id="mandelbrot" width="670" height="670" onclick="draw2(event);">
    1.44 -</canvas> 
    1.45 -<button onclick="draw(0, -2, 0, 0, 0);">Left</button>
    1.46 -<button onclick="draw(0, 2, 0, 0, 0);">Right</button>
    1.47 -<button onclick="draw(0, 0, -2, 0, 0)">Up</button>
    1.48 -<button onclick="draw(0, 0, 2, 0, 0);">Down</button>
    1.49 -<button onclick="draw(0, 0, 0, 2, 0);">Zoom in</button>
    1.50 -<button onclick="draw(0, 0, 0, -2, 0);">Zoom out</button>
    1.51 -<button onclick="draw(0, 0, 0, 0, -1);">Inc Resolution</button>
    1.52 -<button onclick="draw(0, 0, 0, 0, 1);">Dec Resolution</button>
    1.53 -<button onclick="draw(100, 0, 0, 0, 0);">Inc Iterations</button>
    1.54 -<button onclick="draw(-100, 0, 0, 0, 0);">Dec Iterations</button>
    1.55 -</p>
    1.56 -
    1.57 -        </div>
    1.58 -        <div id="sidebar">
    1.59 -          <p>           
    1.60 -	    <a href="resume.html" class="float-left"></a>            
    1.61 -            I'm a programmer,<br />
    1.62 -            a student of computer science,<br />
    1.63 -            a music enthusiast.<br />
    1.64 -            This is my site.
    1.65 -          </p>
    1.66 -          <div id="random_quote"></div>
    1.67 -        </div>
    1.68 -      </div>
    1.69 -      <div id="footer">
    1.70 -        <div id="footer-left">
    1.71 -          <p>
    1.72 -            <a href="mailto:sawine@me73.com">
    1.73 -	      Eugen Sawin<br/>Software Enginnering &amp; Research</a>
    1.74 -          </p>
    1.75 -        </div>
    1.76 -        <div id="footer-right">
    1.77 -          <p class="align-right">
    1.78 -            <a href="index.html">Home</a> | <a href="#top">Top</a>
    1.79 -          </p>
    1.80 -        </div>
    1.81 -      </div>
    1.82 -    </div>
    1.83 -    <script type="application/javascript">
    1.84 -      javascript:load_random_quote();
    1.85 -    </script>
    1.86 -  </body>
    1.87 -</html>
    1.88 -
     2.1 --- a/factory/create_page	Thu Jan 05 23:29:27 2012 +0100
     2.2 +++ b/factory/create_page	Fri Jan 06 00:02:26 2012 +0100
     2.3 @@ -5,7 +5,7 @@
     2.4  from optparse import OptionParser
     2.5  
     2.6  content_dir = "v2012"
     2.7 -content_files = ("index.html", "resume.html", "howiwork.html", "personalwork.html", "books.html", "links.html", "experiments.html", "linksend.html", "gameoflife.html")
     2.8 +content_files = ("index.html", "resume.html", "howiwork.html", "personalwork.html", "books.html", "links.html", "experiments.html", "linksend.html", "gameoflife.html", "mandelbrot.html")
     2.9  
    2.10  def create_page(frame_filename, content_filename, output_filename):
    2.11     frame_file = open(frame_filename, "r")
     3.1 --- a/factory/v2012/experiments.html	Thu Jan 05 23:29:27 2012 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,16 +0,0 @@
     3.4 -<p>
     3.5 -<!--<img src="images/world.png" alt="world map" height="280" width="100%" />
     3.6 --->
     3.7 -<canvas id="mandelbrot" width="670" height="670" onclick="draw2(event);">
     3.8 -</canvas> 
     3.9 -<button onclick="draw(0, -2, 0, 0, 0);">Left</button>
    3.10 -<button onclick="draw(0, 2, 0, 0, 0);">Right</button>
    3.11 -<button onclick="draw(0, 0, -2, 0, 0)">Up</button>
    3.12 -<button onclick="draw(0, 0, 2, 0, 0);">Down</button>
    3.13 -<button onclick="draw(0, 0, 0, 2, 0);">Zoom in</button>
    3.14 -<button onclick="draw(0, 0, 0, -2, 0);">Zoom out</button>
    3.15 -<button onclick="draw(0, 0, 0, 0, -1);">Inc Resolution</button>
    3.16 -<button onclick="draw(0, 0, 0, 0, 1);">Dec Resolution</button>
    3.17 -<button onclick="draw(100, 0, 0, 0, 0);">Inc Iterations</button>
    3.18 -<button onclick="draw(-100, 0, 0, 0, 0);">Dec Iterations</button>
    3.19 -</p>
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/factory/v2012/mandelbrot.html	Fri Jan 06 00:02:26 2012 +0100
     4.3 @@ -0,0 +1,16 @@
     4.4 +<p>
     4.5 +<!--<img src="images/world.png" alt="world map" height="280" width="100%" />
     4.6 +-->
     4.7 +<canvas id="mandelbrot" width="670" height="670" onclick="draw2(event);">
     4.8 +</canvas> 
     4.9 +<button onclick="draw(0, -2, 0, 0, 0);">Left</button>
    4.10 +<button onclick="draw(0, 2, 0, 0, 0);">Right</button>
    4.11 +<button onclick="draw(0, 0, -2, 0, 0)">Up</button>
    4.12 +<button onclick="draw(0, 0, 2, 0, 0);">Down</button>
    4.13 +<button onclick="draw(0, 0, 0, 2, 0);">Zoom in</button>
    4.14 +<button onclick="draw(0, 0, 0, -2, 0);">Zoom out</button>
    4.15 +<button onclick="draw(0, 0, 0, 0, -1);">Inc Resolution</button>
    4.16 +<button onclick="draw(0, 0, 0, 0, 1);">Dec Resolution</button>
    4.17 +<button onclick="draw(100, 0, 0, 0, 0);">Inc Iterations</button>
    4.18 +<button onclick="draw(-100, 0, 0, 0, 0);">Dec Iterations</button>
    4.19 +</p>
     5.1 --- a/factory/v2012/script.js	Thu Jan 05 23:29:27 2012 +0100
     5.2 +++ b/factory/v2012/script.js	Fri Jan 06 00:02:26 2012 +0100
     5.3 @@ -299,7 +299,7 @@
     5.4  function init_gameoflife() {
     5.5      var canvas = document.getElementById("gameoflife");
     5.6      if (canvas) {
     5.7 -        gameoflife = new Simulation(canvas, 670, 670, 8,
     5.8 +        gameoflife = new Simulation(canvas, 670, 670, 16,
     5.9                                      green, black);
    5.10          $("#gameoflife").mousemove(function(event) { 
    5.11              gameoflife.mouse_moved(mouse_pos(event, "#gameoflife")); 
    5.12 @@ -657,7 +657,8 @@
    5.13  Simulation.prototype.draw = function() {
    5.14      var now = $.now();
    5.15      if (this.redraw.length) {
    5.16 -        var cell = this.redraw.pop();
    5.17 +        var cell = this.redraw[0];
    5.18 +        this.redraw.shift();
    5.19          this.context.fillStyle = cell.value == 1 ? 
    5.20              this.life_colour.str() : this.dead_colour.str();
    5.21          this.context.fillRect(cell.canvas_x, cell.canvas_y, 
    5.22 @@ -668,14 +669,14 @@
    5.23  Simulation.prototype.update = function() {
    5.24      var now = $.now();
    5.25      if (this.pos_queue.length) {
    5.26 -        var pos = this.pos_queue.pop();
    5.27 +        var pos = this.pos_queue.pop();       
    5.28          if (pos[0] < this.canvas.width
    5.29              && pos[1] < this.canvas.height) {
    5.30              var cell = this.grid.pick_cell(pos[0], pos[1]);
    5.31              cell.set_value(1);
    5.32              this.cell_queue.push(cell);
    5.33              this.cell_queue.concat(cell.neighbours()); 
    5.34 -            this.redraw.push(cell);          
    5.35 +            this.redraw.unshift(cell);          
    5.36          }
    5.37      }
    5.38      if (this.last_update + 1000 > now) {
    5.39 @@ -684,7 +685,7 @@
    5.40      var changed = new Array();
    5.41      var next_cell_queue = new Array();
    5.42      while (this.cell_queue.length) {
    5.43 -        var cell = this.cell_queue.pop();
    5.44 +        var cell = this.cell_queue.pop();       
    5.45          if (changed[cell.hash()]) {           
    5.46              continue;
    5.47          }
    5.48 @@ -704,7 +705,7 @@
    5.49          cell.set_value(1 - cell.value);
    5.50          this.redraw.push(cell);
    5.51      }
    5.52 -    this.cell_queue = this.cell_queue.concat(next_cell_queue);
    5.53 +    this.cell_queue = next_cell_queue;
    5.54      this.last_update = now;  
    5.55  }
    5.56  Simulation.prototype.mouse_moved = function(pos) {
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/mandelbrot.html	Fri Jan 06 00:02:26 2012 +0100
     6.3 @@ -0,0 +1,85 @@
     6.4 +<!DOCTYPE html>
     6.5 +<html lang="en">
     6.6 +  <head>
     6.7 +    <title>ME73</title>
     6.8 +    <meta name="author" content="Eugen Sawin <sawine@me73.com>" />
     6.9 +    <meta name="description" content="A Digital Playground" />
    6.10 +    <meta name="robots" content="index, follow, noarchive" />
    6.11 +    <meta name="googlebot" content="noarchive" />
    6.12 +    <script src="jquery.js"></script>
    6.13 +    <script src="script.js"></script>
    6.14 +    <link rel="stylesheet" href="dark.css" type="text/css" />
    6.15 +    <script type="application/javascript">
    6.16 +      var _gaq = _gaq || [];
    6.17 +      _gaq.push(['_setAccount', 'UA-2137333-1']);
    6.18 +      _gaq.push(['_trackPageview']);
    6.19 +      (function() {
    6.20 +      var ga = document.createElement('script'); ga.type = 'text/javascript';
    6.21 +      ga.async = true;
    6.22 +      ga.src = ('https:' == document.location.protocol ? 'https://ssl' :'http://www') 
    6.23 +      + '.google-analytics.com/ga.js';
    6.24 +      var s = document.getElementsByTagName('script')[0];
    6.25 +      s.parentNode.insertBefore(ga, s);
    6.26 +      })();
    6.27 +    </script>
    6.28 +  </head>
    6.29 +  <body>
    6.30 +    <div id="wrap">
    6.31 +      <div id="header">
    6.32 +        <canvas id="logo">
    6.33 +          FIND A BETTER BROWSER
    6.34 +        </canvas>
    6.35 +        <canvas id="sim">
    6.36 +        </canvas>
    6.37 +      </div>
    6.38 +      <div id="content-wrap">
    6.39 +        <div id="main">
    6.40 +          <p>
    6.41 +<!--<img src="images/world.png" alt="world map" height="280" width="100%" />
    6.42 +-->
    6.43 +<canvas id="mandelbrot" width="670" height="670" onclick="draw2(event);">
    6.44 +</canvas> 
    6.45 +<button onclick="draw(0, -2, 0, 0, 0);">Left</button>
    6.46 +<button onclick="draw(0, 2, 0, 0, 0);">Right</button>
    6.47 +<button onclick="draw(0, 0, -2, 0, 0)">Up</button>
    6.48 +<button onclick="draw(0, 0, 2, 0, 0);">Down</button>
    6.49 +<button onclick="draw(0, 0, 0, 2, 0);">Zoom in</button>
    6.50 +<button onclick="draw(0, 0, 0, -2, 0);">Zoom out</button>
    6.51 +<button onclick="draw(0, 0, 0, 0, -1);">Inc Resolution</button>
    6.52 +<button onclick="draw(0, 0, 0, 0, 1);">Dec Resolution</button>
    6.53 +<button onclick="draw(100, 0, 0, 0, 0);">Inc Iterations</button>
    6.54 +<button onclick="draw(-100, 0, 0, 0, 0);">Dec Iterations</button>
    6.55 +</p>
    6.56 +
    6.57 +        </div>
    6.58 +        <div id="sidebar">
    6.59 +          <p>           
    6.60 +	    <a href="resume.html" class="float-left"></a>            
    6.61 +            I'm a programmer,<br />
    6.62 +            a student of computer science,<br />
    6.63 +            a music enthusiast.<br />
    6.64 +            This is my site.
    6.65 +          </p>
    6.66 +          <div id="random_quote"></div>
    6.67 +        </div>
    6.68 +      </div>
    6.69 +      <div id="footer">
    6.70 +        <div id="footer-left">
    6.71 +          <p>
    6.72 +            <a href="mailto:sawine@me73.com">
    6.73 +	      Eugen Sawin<br/>Software Enginnering &amp; Research</a>
    6.74 +          </p>
    6.75 +        </div>
    6.76 +        <div id="footer-right">
    6.77 +          <p class="align-right">
    6.78 +            <a href="index.html">Home</a> | <a href="#top">Top</a>
    6.79 +          </p>
    6.80 +        </div>
    6.81 +      </div>
    6.82 +    </div>
    6.83 +    <script type="application/javascript">
    6.84 +      javascript:load_random_quote();
    6.85 +    </script>
    6.86 +  </body>
    6.87 +</html>
    6.88 +
     7.1 --- a/script.js	Thu Jan 05 23:29:27 2012 +0100
     7.2 +++ b/script.js	Fri Jan 06 00:02:26 2012 +0100
     7.3 @@ -299,7 +299,7 @@
     7.4  function init_gameoflife() {
     7.5      var canvas = document.getElementById("gameoflife");
     7.6      if (canvas) {
     7.7 -        gameoflife = new Simulation(canvas, 670, 670, 8,
     7.8 +        gameoflife = new Simulation(canvas, 670, 670, 16,
     7.9                                      green, black);
    7.10          $("#gameoflife").mousemove(function(event) { 
    7.11              gameoflife.mouse_moved(mouse_pos(event, "#gameoflife")); 
    7.12 @@ -615,9 +615,7 @@
    7.13          if (this.y + 1 < this.grid.height) {
    7.14              this._neighbours.push(this.grid.cell(this.x-1, this.y+1));
    7.15          }
    7.16 -    } else {
    7.17 -        this._neighbours.push(this.grid.cell(this.grid.width-1, this.y));
    7.18 -    }
    7.19 +    }   
    7.20      if (this.x + 1 < this.grid.width) {
    7.21          this._neighbours.push(this.grid.cell(this.x+1, this.y));
    7.22          if (this.y + 1 < this.grid.height) {
    7.23 @@ -627,8 +625,6 @@
    7.24          if (this.y > 0) {
    7.25              this._neighbours.push(this.grid.cell(this.x+1, this.y-1));
    7.26          }
    7.27 -    } else {
    7.28 -        this._neighbours.push(this.grid.cell(0, this.y));
    7.29      }
    7.30      return this._neighbours;
    7.31  }
    7.32 @@ -661,7 +657,8 @@
    7.33  Simulation.prototype.draw = function() {
    7.34      var now = $.now();
    7.35      if (this.redraw.length) {
    7.36 -        var cell = this.redraw.pop();
    7.37 +        var cell = this.redraw[0];
    7.38 +        this.redraw.shift();
    7.39          this.context.fillStyle = cell.value == 1 ? 
    7.40              this.life_colour.str() : this.dead_colour.str();
    7.41          this.context.fillRect(cell.canvas_x, cell.canvas_y, 
    7.42 @@ -672,14 +669,14 @@
    7.43  Simulation.prototype.update = function() {
    7.44      var now = $.now();
    7.45      if (this.pos_queue.length) {
    7.46 -        var pos = this.pos_queue.pop();
    7.47 +        var pos = this.pos_queue.pop();       
    7.48          if (pos[0] < this.canvas.width
    7.49              && pos[1] < this.canvas.height) {
    7.50              var cell = this.grid.pick_cell(pos[0], pos[1]);
    7.51              cell.set_value(1);
    7.52              this.cell_queue.push(cell);
    7.53              this.cell_queue.concat(cell.neighbours()); 
    7.54 -            this.redraw.push(cell);          
    7.55 +            this.redraw.unshift(cell);          
    7.56          }
    7.57      }
    7.58      if (this.last_update + 1000 > now) {
    7.59 @@ -688,7 +685,7 @@
    7.60      var changed = new Array();
    7.61      var next_cell_queue = new Array();
    7.62      while (this.cell_queue.length) {
    7.63 -        var cell = this.cell_queue.pop();
    7.64 +        var cell = this.cell_queue.pop();       
    7.65          if (changed[cell.hash()]) {           
    7.66              continue;
    7.67          }
    7.68 @@ -708,7 +705,7 @@
    7.69          cell.set_value(1 - cell.value);
    7.70          this.redraw.push(cell);
    7.71      }
    7.72 -    this.cell_queue = this.cell_queue.concat(next_cell_queue);
    7.73 +    this.cell_queue = next_cell_queue;
    7.74      this.last_update = now;  
    7.75  }
    7.76  Simulation.prototype.mouse_moved = function(pos) {