# HG changeset patch # User Eugen Sawin # Date 1325804546 -3600 # Node ID 228adcfd8f23334e7fc49df8bc534995870c2ffb # Parent cb8897d7f508521531aa20be1401dc3dfe2ce099 Renamed mandelbrot experiment. diff -r cb8897d7f508 -r 228adcfd8f23 experiments.html --- a/experiments.html Thu Jan 05 23:29:27 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ - - - - ME73 - - - - - - - - - - -
- -
-
-

- - - - - - - - - - - - - -

- -
- -
- -
- - - - diff -r cb8897d7f508 -r 228adcfd8f23 factory/create_page --- a/factory/create_page Thu Jan 05 23:29:27 2012 +0100 +++ b/factory/create_page Fri Jan 06 00:02:26 2012 +0100 @@ -5,7 +5,7 @@ from optparse import OptionParser content_dir = "v2012" -content_files = ("index.html", "resume.html", "howiwork.html", "personalwork.html", "books.html", "links.html", "experiments.html", "linksend.html", "gameoflife.html") +content_files = ("index.html", "resume.html", "howiwork.html", "personalwork.html", "books.html", "links.html", "experiments.html", "linksend.html", "gameoflife.html", "mandelbrot.html") def create_page(frame_filename, content_filename, output_filename): frame_file = open(frame_filename, "r") diff -r cb8897d7f508 -r 228adcfd8f23 factory/v2012/experiments.html --- a/factory/v2012/experiments.html Thu Jan 05 23:29:27 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -

- - - - - - - - - - - - - -

diff -r cb8897d7f508 -r 228adcfd8f23 factory/v2012/mandelbrot.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/factory/v2012/mandelbrot.html Fri Jan 06 00:02:26 2012 +0100 @@ -0,0 +1,16 @@ +

+ + + + + + + + + + + + + +

diff -r cb8897d7f508 -r 228adcfd8f23 factory/v2012/script.js --- a/factory/v2012/script.js Thu Jan 05 23:29:27 2012 +0100 +++ b/factory/v2012/script.js Fri Jan 06 00:02:26 2012 +0100 @@ -299,7 +299,7 @@ function init_gameoflife() { var canvas = document.getElementById("gameoflife"); if (canvas) { - gameoflife = new Simulation(canvas, 670, 670, 8, + gameoflife = new Simulation(canvas, 670, 670, 16, green, black); $("#gameoflife").mousemove(function(event) { gameoflife.mouse_moved(mouse_pos(event, "#gameoflife")); @@ -657,7 +657,8 @@ Simulation.prototype.draw = function() { var now = $.now(); if (this.redraw.length) { - var cell = this.redraw.pop(); + var cell = this.redraw[0]; + this.redraw.shift(); this.context.fillStyle = cell.value == 1 ? this.life_colour.str() : this.dead_colour.str(); this.context.fillRect(cell.canvas_x, cell.canvas_y, @@ -668,14 +669,14 @@ Simulation.prototype.update = function() { var now = $.now(); if (this.pos_queue.length) { - var pos = this.pos_queue.pop(); + var pos = this.pos_queue.pop(); if (pos[0] < this.canvas.width && pos[1] < this.canvas.height) { var cell = this.grid.pick_cell(pos[0], pos[1]); cell.set_value(1); this.cell_queue.push(cell); this.cell_queue.concat(cell.neighbours()); - this.redraw.push(cell); + this.redraw.unshift(cell); } } if (this.last_update + 1000 > now) { @@ -684,7 +685,7 @@ var changed = new Array(); var next_cell_queue = new Array(); while (this.cell_queue.length) { - var cell = this.cell_queue.pop(); + var cell = this.cell_queue.pop(); if (changed[cell.hash()]) { continue; } @@ -704,7 +705,7 @@ cell.set_value(1 - cell.value); this.redraw.push(cell); } - this.cell_queue = this.cell_queue.concat(next_cell_queue); + this.cell_queue = next_cell_queue; this.last_update = now; } Simulation.prototype.mouse_moved = function(pos) { diff -r cb8897d7f508 -r 228adcfd8f23 mandelbrot.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mandelbrot.html Fri Jan 06 00:02:26 2012 +0100 @@ -0,0 +1,85 @@ + + + + ME73 + + + + + + + + + + +
+ +
+
+

+ + + + + + + + + + + + + +

+ +
+ +
+ +
+ + + + diff -r cb8897d7f508 -r 228adcfd8f23 script.js --- a/script.js Thu Jan 05 23:29:27 2012 +0100 +++ b/script.js Fri Jan 06 00:02:26 2012 +0100 @@ -299,7 +299,7 @@ function init_gameoflife() { var canvas = document.getElementById("gameoflife"); if (canvas) { - gameoflife = new Simulation(canvas, 670, 670, 8, + gameoflife = new Simulation(canvas, 670, 670, 16, green, black); $("#gameoflife").mousemove(function(event) { gameoflife.mouse_moved(mouse_pos(event, "#gameoflife")); @@ -615,9 +615,7 @@ if (this.y + 1 < this.grid.height) { this._neighbours.push(this.grid.cell(this.x-1, this.y+1)); } - } else { - this._neighbours.push(this.grid.cell(this.grid.width-1, this.y)); - } + } if (this.x + 1 < this.grid.width) { this._neighbours.push(this.grid.cell(this.x+1, this.y)); if (this.y + 1 < this.grid.height) { @@ -627,8 +625,6 @@ if (this.y > 0) { this._neighbours.push(this.grid.cell(this.x+1, this.y-1)); } - } else { - this._neighbours.push(this.grid.cell(0, this.y)); } return this._neighbours; } @@ -661,7 +657,8 @@ Simulation.prototype.draw = function() { var now = $.now(); if (this.redraw.length) { - var cell = this.redraw.pop(); + var cell = this.redraw[0]; + this.redraw.shift(); this.context.fillStyle = cell.value == 1 ? this.life_colour.str() : this.dead_colour.str(); this.context.fillRect(cell.canvas_x, cell.canvas_y, @@ -672,14 +669,14 @@ Simulation.prototype.update = function() { var now = $.now(); if (this.pos_queue.length) { - var pos = this.pos_queue.pop(); + var pos = this.pos_queue.pop(); if (pos[0] < this.canvas.width && pos[1] < this.canvas.height) { var cell = this.grid.pick_cell(pos[0], pos[1]); cell.set_value(1); this.cell_queue.push(cell); this.cell_queue.concat(cell.neighbours()); - this.redraw.push(cell); + this.redraw.unshift(cell); } } if (this.last_update + 1000 > now) { @@ -688,7 +685,7 @@ var changed = new Array(); var next_cell_queue = new Array(); while (this.cell_queue.length) { - var cell = this.cell_queue.pop(); + var cell = this.cell_queue.pop(); if (changed[cell.hash()]) { continue; } @@ -708,7 +705,7 @@ cell.set_value(1 - cell.value); this.redraw.push(cell); } - this.cell_queue = this.cell_queue.concat(next_cell_queue); + this.cell_queue = next_cell_queue; this.last_update = now; } Simulation.prototype.mouse_moved = function(pos) {