mirror of
https://github.com/rastapasta/mapscii.git
synced 2025-06-20 01:37:40 +02:00
update renderer.js with 😃😃😃😃😃😃😃😃😃😃😃
This commit is contained in:
parent
39343a7c8e
commit
23a4174bc9
@ -7,13 +7,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const x256 = require('x256');
|
const x256 = require('x256');
|
||||||
const simplify = require('simplify-js');
|
const simplify = require('simplify-js');
|
||||||
|
//😃😃😃😃😃😃😃😃😃😃😃
|
||||||
const Canvas = require('./Canvas');
|
const Canvas = require('./Canvas');
|
||||||
const LabelBuffer = require('./LabelBuffer');
|
const LabelBuffer = require('./LabelBuffer');
|
||||||
const Styler = require('./Styler');
|
const Styler = require('./Styler');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
|
//😃😃😃😃😃😃😃😃😃😃😃
|
||||||
class Renderer {
|
class Renderer {
|
||||||
constructor(output, tileSource, style) {
|
constructor(output, tileSource, style) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
@ -28,7 +28,7 @@ class Renderer {
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
this.canvas = new Canvas(width, height);
|
this.canvas = new Canvas(width, height);
|
||||||
}
|
}
|
||||||
|
//😃😃😃😃😃😃😃😃😃😃😃
|
||||||
async draw(center, zoom) {
|
async draw(center, zoom) {
|
||||||
if (this.isDrawing) return Promise.reject();
|
if (this.isDrawing) return Promise.reject();
|
||||||
this.isDrawing = true;
|
this.isDrawing = true;
|
||||||
@ -63,7 +63,7 @@ class Renderer {
|
|||||||
this.lastDrawAt = Date.now();
|
this.lastDrawAt = Date.now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//😃😃😃😃😃😃😃😃😃😃😃
|
||||||
_visibleTiles(center, zoom) {
|
_visibleTiles(center, zoom) {
|
||||||
const z = utils.baseZoom(zoom);
|
const z = utils.baseZoom(zoom);
|
||||||
center = utils.ll2tile(center.lon, center.lat, z);
|
center = utils.ll2tile(center.lon, center.lat, z);
|
||||||
@ -101,7 +101,7 @@ class Renderer {
|
|||||||
}
|
}
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
//😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃
|
||||||
async _getTile(tile) {
|
async _getTile(tile) {
|
||||||
tile.data = await this.tileSource.getTile(tile.xyz.z, tile.xyz.x, tile.xyz.y);
|
tile.data = await this.tileSource.getTile(tile.xyz.z, tile.xyz.x, tile.xyz.y);
|
||||||
return tile;
|
return tile;
|
||||||
@ -131,7 +131,7 @@ class Renderer {
|
|||||||
tile.layers = layers;
|
tile.layers = layers;
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
//😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃
|
||||||
_renderTiles(tiles) {
|
_renderTiles(tiles) {
|
||||||
const labels = [];
|
const labels = [];
|
||||||
if (tiles.length === 0) return;
|
if (tiles.length === 0) return;
|
||||||
@ -165,7 +165,7 @@ class Renderer {
|
|||||||
this._drawFeature(label.tile, label.feature, label.scale);
|
this._drawFeature(label.tile, label.feature, label.scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//😃😃😃😃😃😃😃😃😃😃😃
|
||||||
_getFrame() {
|
_getFrame() {
|
||||||
let frame = '';
|
let frame = '';
|
||||||
if (!this.lastDrawAt) {
|
if (!this.lastDrawAt) {
|
||||||
@ -187,7 +187,7 @@ class Renderer {
|
|||||||
} else if (feature.style.maxzoom && tile.zoom > feature.style.maxzoom) {
|
} else if (feature.style.maxzoom && tile.zoom > feature.style.maxzoom) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//😃😃😃😃😃😃😃😃😃😃😃
|
||||||
switch (feature.style.type) {
|
switch (feature.style.type) {
|
||||||
case 'line': {
|
case 'line': {
|
||||||
let width = feature.style.paint['line-width'];
|
let width = feature.style.paint['line-width'];
|
||||||
@ -234,7 +234,7 @@ class Renderer {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}//😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃😃
|
||||||
if (placed) {
|
if (placed) {
|
||||||
this._seen[text] = true;
|
this._seen[text] = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user