be more smarter about when to render templates

This commit is contained in:
HF 2024-02-22 10:42:23 +01:00
parent 3b590c4091
commit 2776f3cea4
2 changed files with 9 additions and 8 deletions

View File

@ -34,7 +34,7 @@ const METHODS = {
let rplPxl = null;
for (let u = -1; u <= 1; u += 1) {
for (let v = -1; v <= 1; v += 1) {
if (u === 0 && v === 0) {
if (u === 0 && v === 0) {
continue;
}
pxl = canvasCleaner.getPixelInChunkArea(xc + u, yc + v);
@ -61,7 +61,7 @@ const METHODS = {
let rplPxl = null;
for (let u = -1; u <= 1; u += 1) {
for (let v = -1; v <= 1; v += 1) {
if (u === 0 && v === 0) {
if (u === 0 && v === 0) {
continue;
}
pxl = canvasCleaner.getPixelInChunkArea(xc + u, yc + v);
@ -92,7 +92,7 @@ const METHODS = {
const origPxl = pxl;
for (let u = -1; u <= 1; u += 1) {
for (let v = -1; v <= 1; v += 1) {
if (u === 0 && v === 0) {
if (u === 0 && v === 0) {
continue;
}
pxl = canvasCleaner.getPixelInChunkArea(xc + u, yc + v);

View File

@ -113,7 +113,7 @@ export function renderOverlay(
tiledScale,
scaleThreshold,
) {
if (!templateLoader.ready) return;
if (!templateLoader.ready || scale < 0.035) return;
const { canvasSize, canvasId } = state.canvas;
// world coordinates of center of center chunk
const [x, y] = centerChunk
@ -139,13 +139,14 @@ export function renderOverlay(
context.scale(offscreenScale, offscreenScale);
context.globalAlpha = state.templates.oOpacity / 100;
for (const template of templates) {
const tempWidth = template.x - x + width / 2 / offscreenScale;
const tempHeight = template.y - y + height / 2 / offscreenScale;
if (tempWidth < 1 || tempHeight < 1) continue;
const image = templateLoader.getTemplateSync(template.imageId);
if (!image) continue;
context.drawImage(image,
template.x - x + width / 2 / offscreenScale,
template.y - y + height / 2 / offscreenScale,
);
context.drawImage(image, tempWidth, tempHeight);
}
context.restore();
}