Re-grow the grid and re-lower the default num of walkers
This commit is contained in:
parent
dcdf2e7c55
commit
f20aee872e
18
walkers.js
18
walkers.js
@ -5,14 +5,14 @@
|
||||
// a rainbow-adjacent set of colors for the walkers to cycle through
|
||||
var walker_colors = [
|
||||
"#ffb000", // amber, from https://superuser.com/a/1206781
|
||||
"#ff7700", // orange
|
||||
"#33ff00", // green, also from https://superuser.com/a/1206781
|
||||
"#ff2e00", // red
|
||||
"#ff7700", // orange
|
||||
"#004cff", // blue
|
||||
"#8500ff", // purple
|
||||
"#ff2e00", // red
|
||||
];
|
||||
// start with a random part of the sequence
|
||||
var color_idx = Math.floor(Math.random() * walker_colors.length);
|
||||
var color_idx = 0;
|
||||
|
||||
// create a new walker with random position and color
|
||||
function create_random_walker() {
|
||||
@ -85,10 +85,10 @@ Number.prototype.div = function(divisor) {
|
||||
* Random walk implementation (movement functions) *
|
||||
****************************************************************************/
|
||||
|
||||
// return a random update time. 10 to 90ms in increments of 20.
|
||||
// return a random update time. 30 to 210ms in increments of 20.
|
||||
function random_update_time() {
|
||||
var speed = Math.floor(Math.random() * 5);
|
||||
return (speed * 20) + 10;
|
||||
var speed = Math.floor(Math.random() * 7);
|
||||
return (speed * 30) + 30;
|
||||
}
|
||||
|
||||
// start up the functions that run FOREVER!!!
|
||||
@ -102,7 +102,7 @@ function init_walk() {
|
||||
if (urlParams.has('n', "0")) {
|
||||
n_create = 0;
|
||||
} else {
|
||||
n_create = Number(urlParams.get('n')) || walker_colors.length;
|
||||
n_create = Number(urlParams.get('nwalk')) || 3;
|
||||
}
|
||||
|
||||
// create initial walkers of every color
|
||||
@ -224,7 +224,7 @@ function fix_grid_size() {
|
||||
|
||||
// draw on the canvas a grid square of that color
|
||||
function draw_grid_square(row, col, color) {
|
||||
var margin = 1;
|
||||
var margin = 4;
|
||||
var pos_h = offset_h + (cell_size * col) + margin;
|
||||
var pos_v = offset_v + (cell_size * row) + margin;
|
||||
|
||||
@ -259,7 +259,7 @@ document
|
||||
.addEventListener("click", destroy_all_walkers);
|
||||
|
||||
// compute the initial rows and columns
|
||||
var cell_size = 8;
|
||||
var cell_size = 22;
|
||||
var n_rows = canvas.height.div(cell_size);
|
||||
var n_cols = canvas.width.div(cell_size);
|
||||
var offset_h = (canvas.width - (cell_size * n_cols)).div(2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user