Skip to content

Commit a56a96d

Browse files
committed
Some old changes being pushed up
1 parent 9f96252 commit a56a96d

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

canvas/life.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@ <h1>Learning the <code>&lt;canvas&gt;</code> and Prototype - playing with Conway
9494
var grid_count = 50;
9595
var grid_size = 10; // In Pixels
9696
var living = 20; // 1-100% of activated cells
97-
var tick_timer = 100; // How frequently to tick
97+
var tick_timer = 5; // How frequently to tick
9898
// Create a game of life
9999
var game = new Life(div_id, grid_count, grid_size, living, tick_timer);
100100
// Start 'er tickin'
101-
window.setTimeout("game.tick()", game.ticktime);
101+
setTimeout(function(){
102+
game.tick();
103+
}, game.ticktime);
102104
</script>
103105
<script type="text/javascript">
104106
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

canvas/waves.html

+12-12
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h1>Learning the <code>&lt;canvas&gt;</code> - Waves</h1>
4242
<div id="base">
4343
<p>Our Canvases</p>
4444
<p>Base:</p>
45-
<canvas id="wavebase" width="150" height="150">No Canvas Support?</canvas>
45+
<canvas id="wavebase" width="300" height="300">No Canvas Support?</canvas>
4646
</div>
4747
<div id="controls">
4848
<ul>
@@ -67,7 +67,7 @@ <h1>Learning the <code>&lt;canvas&gt;</code> - Waves</h1>
6767
// Set up variables
6868
var src, ctx, imgd, i, j, w, h, midx, midy, FRAMERATE, DAMP, count, waves, wold, wnew, wavetable, tmp;
6969
FRAMERATE = 100;
70-
DAMP = 50;
70+
DAMP = 250;
7171
src = $("#wavebase");
7272
w = src.attr("width");
7373
h = src.attr("height");
@@ -105,7 +105,7 @@ <h1>Learning the <code>&lt;canvas&gt;</code> - Waves</h1>
105105

106106
// Drawing function
107107
function drawIt() {
108-
var c, index, val;
108+
var c, index, val, data = imgd.data;
109109

110110
// Loop over rows, excluding edge
111111
//for (i = 0; i < h; ++i) if had edge
@@ -161,23 +161,23 @@ <h1>Learning the <code>&lt;canvas&gt;</code> - Waves</h1>
161161
case 1:
162162
/*
163163
if (val > 0) {
164-
//imgd.data[index + c] = val * 200 + 55;
165-
imgd.data[index + c] = 255;
164+
//data[index + c] = val * 200 + 55;
165+
data[index + c] = 255;
166166
} else {
167-
//imgd.data[index + c] = 255 - val * 50;
168-
imgd.data[index + c] = 0;
167+
//data[index + c] = 255 - val * 50;
168+
data[index + c] = 0;
169169
}
170170
*/
171-
imgd.data[index + c] = val + 127;
171+
data[index + c] = val + 127;
172172
break;
173173
case 2:
174-
//imgd.data[index + c] = waves[wnew][i][j] * 2.55;
175-
//imgd.data[index + c] = (val + 127) % 255;
176-
imgd.data[index + c] = 255;
174+
//data[index + c] = waves[wnew][i][j] * 2.55;
175+
//data[index + c] = (val + 127) % 255;
176+
data[index + c] = 255;
177177
break;
178178
case 3:
179179
// 0 is transparent, 255 is opaque;
180-
imgd.data[index + c] = 255;
180+
data[index + c] = 255;
181181
break;
182182
} // switch(c)
183183
} // for var c, three colors

0 commit comments

Comments
 (0)