Skip to content

Commit

Permalink
TODO updated
Browse files Browse the repository at this point in the history
  • Loading branch information
nakednous committed Feb 3, 2021
1 parent b22f7f3 commit 71ab01b
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions p5.quadrille.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,44 @@ class Quadrille {
return this._memory2D.length;
}

/**
* Same as width * height.
*/
get size() {
return this.width * this.height;
}

/**
* @returns {number} Number of non-empty queadrille cells.
*/
get order() {
let result = 0;
for (let i = 0; i < this.height; i++) {
for (let j = 0; j < this.width; j++) {
if (this.memory2D[i][j]) {
result++;
}
}
}
return result;
}

/**
* @param {number} row.
* @returns {number} Number of non-empty quadrille cells at row.
*/
magnitude(row) {
let result = 0;
for (let j = 0; j < this.width; j++) {
if (this.memory2D[row][j]) {
result++;
}
}
return result;
}

// TODO isPolyomino

/**
* Replaces quadrille cells with given pattern. Either:
* 1. replace(pattern1, pattern2), search pattern1 and replaces with pattern2,
Expand Down Expand Up @@ -298,42 +336,6 @@ class Quadrille {
}
}

/**
* @param {number} row.
* @returns {number} Number of non-empty quadrille cells at row.
*/
magnitude(row) {
let result = 0;
for (let j = 0; j < this.width; j++) {
if (this.memory2D[row][j]) {
result++;
}
}
return result;
}

/**
* @returns {number} Number of non-empty queadrille cells.
*/
get order() {
let result = 0;
for (let i = 0; i < this.height; i++) {
for (let j = 0; j < this.width; j++) {
if (this.memory2D[i][j]) {
result++;
}
}
}
return result;
}

/**
* Same as width * height.
*/
get size() {
return this.width * this.height;
}

/**
* @returns {number} Quadrille int representation using big-endian and row-major ordering
* of the memory2D entries.
Expand All @@ -350,7 +352,7 @@ class Quadrille {
return result;
}

// TODO perlin noise is missed
// TODO perlin noise

/**
* Randomly fills quadrille with pattern up to order.
Expand Down

0 comments on commit 71ab01b

Please sign in to comment.