mirror of
https://github.com/sbrl/terrain50-cli.git
synced 2024-11-23 07:03:01 +00:00
Well, that was a failed experiment.
We will probably come back to multithreading the renderer here, but for now we don't actually need it I don't think.
This commit is contained in:
parent
8a846931d9
commit
01a97d04a1
2 changed files with 15 additions and 7 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "terrain50-cli",
|
"name": "terrain50-cli",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -6,7 +6,8 @@ import encode from 'image-encode';
|
||||||
import l from '../../Helpers/Log.mjs';
|
import l from '../../Helpers/Log.mjs';
|
||||||
|
|
||||||
class Terrain50Renderer {
|
class Terrain50Renderer {
|
||||||
constructor(in_scale_factor) {
|
constructor(in_scale_factor, in_domain = "auto") {
|
||||||
|
this.colour_domain = in_domain;
|
||||||
this.scale_factor = in_scale_factor;
|
this.scale_factor = in_scale_factor;
|
||||||
this.colour_scale = chroma.scale([
|
this.colour_scale = chroma.scale([
|
||||||
"#333333",
|
"#333333",
|
||||||
|
@ -26,15 +27,22 @@ class Terrain50Renderer {
|
||||||
* @return {ArrayBuffer} A canvas with the image rendered on it.
|
* @return {ArrayBuffer} A canvas with the image rendered on it.
|
||||||
*/
|
*/
|
||||||
async do_render(terrain) {
|
async do_render(terrain) {
|
||||||
let min = terrain.min_value, max = terrain.max_value;
|
let colour_domain = null;
|
||||||
let colour_domain = this.colour_scale.domain([
|
if(this.colour_domain === "auto") {
|
||||||
min, max
|
let min = terrain.min_value, max = terrain.max_value;
|
||||||
]);
|
colour_domain = this.colour_scale.domain([
|
||||||
|
min, max
|
||||||
|
]);
|
||||||
|
l.log(`[Terrain50Renderer] Automatic colour domain: ${min} - ${max}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
colour_domain = this.colour_scale.domain(this.colour_domain);
|
||||||
|
l.log(`[Terrain50Renderer] Static colour domain: ${this.colour_domain[0]} - ${this.colour_domain[1]}`);
|
||||||
|
}
|
||||||
|
|
||||||
let width = Math.floor(terrain.meta.ncols / this.scale_factor),
|
let width = Math.floor(terrain.meta.ncols / this.scale_factor),
|
||||||
height = Math.floor(terrain.meta.nrows / this.scale_factor);
|
height = Math.floor(terrain.meta.nrows / this.scale_factor);
|
||||||
|
|
||||||
l.log(`[Terrain50Renderer] Colour domain: ${min} - ${max}`);
|
|
||||||
l.log(`[Terrain50Renderer] Dimensions: ${width}x${height}`);
|
l.log(`[Terrain50Renderer] Dimensions: ${width}x${height}`);
|
||||||
|
|
||||||
// Create the image
|
// Create the image
|
||||||
|
|
Loading…
Reference in a new issue