randiny
Version:
<h1 style="margin-bottom: 0">Randiny</h1> <h2 style="font-size: 14px; margin-top: 0">A pseudo random number generator, capable of generating random numbers, and noise maps.</h2>
81 lines • 2.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StaticMap3D = exports.StaticMap2D = exports.StaticMap1D = void 0;
class StaticMap1D {
constructor(rng, length) {
this.map = new Array(length).fill(0).map(e => rng.nextValue());
}
get(index) {
return this.map[index];
}
/**
* Get a range of the map
* @param start Start of the range you want to find. Inclusive
* @param end End of the range you want to find. Inclusive
*/
getRange(start, end) {
this.map.slice(start, (end - start) + 1);
}
getFullMap() {
return this.map;
}
}
exports.StaticMap1D = StaticMap1D;
class StaticMap2D {
constructor(rng, width, height) {
this.map = new Array(height).fill(0).map(e => new Array(width).fill(0).map(e => rng.nextValue()));
}
get(x, y) {
return this.map[y][x];
}
getRow(y) {
return this.map[y];
}
getCol(x) {
const newArr = [];
this.map.forEach((row) => {
newArr.push(row[x]);
});
return newArr;
}
/**
* Returns a yx array of rows like this.\
* [row,row,row]
*/
getFullMap() {
return this.map;
}
}
exports.StaticMap2D = StaticMap2D;
class StaticMap3D {
constructor(rng, width, height, depth) {
this.map = new Array(height).fill(0).map(e => new Array(width).fill(0).map(e => new Array(depth).fill(0).map(e => rng.nextValue())));
}
get(x, y, z) {
return this.map[y][x][z];
}
getRow(y) {
return this.map[y];
}
getCol(x) {
const newArr = [];
this.map.forEach((row) => {
newArr.push(row[x]);
});
return newArr;
}
getDepths(x, y) {
return this.map[y][x];
}
/**
* Returns a yx array of columns like this.\
* [row,row,row]\
* each row like this
* [depths,depths,depths]
*/
getFullMap() {
return this.map;
}
}
exports.StaticMap3D = StaticMap3D;
//# sourceMappingURL=StaticMap.js.map