care about canvas the template is on
This commit is contained in:
parent
d07f20047a
commit
286ccee62e
|
@ -415,7 +415,8 @@ class PixelPainterControls {
|
|||
return renderer.getColorIndexOfPixel(...cell, true);
|
||||
}
|
||||
if (state.gui.holdPaint === HOLD_PAINT.OVERLAY) {
|
||||
const rgb = templateLoader.getColorOfPixel(...cell);
|
||||
const { canvasId } = state.canvas;
|
||||
const rgb = templateLoader.getColorOfPixel(canvasId, ...cell);
|
||||
if (!rgb) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -557,7 +557,7 @@ class Renderer2D extends Renderer {
|
|||
if (viewscale >= 5 && state.templates.ovEnabled
|
||||
&& state.templates.oSmallPxls
|
||||
) {
|
||||
renderSmallPOverlay(viewport, _view, viewscale);
|
||||
renderSmallPOverlay(state, viewport, _view, viewscale);
|
||||
}
|
||||
|
||||
if (showGrid && viewscale >= 8) {
|
||||
|
|
|
@ -114,7 +114,7 @@ export function renderOverlay(
|
|||
scaleThreshold,
|
||||
) {
|
||||
if (!templateLoader.ready) return;
|
||||
const { canvasSize } = state.canvas;
|
||||
const { canvasSize, canvasId } = state.canvas;
|
||||
// world coordinates of center of center chunk
|
||||
const [x, y] = centerChunk
|
||||
.map((z) => z * TILE_SIZE / tiledScale
|
||||
|
@ -123,7 +123,7 @@ export function renderOverlay(
|
|||
const horizontalRadius = width / 2 / scale;
|
||||
const verticalRadius = height / 2 / scale;
|
||||
const templates = templateLoader.getTemplatesInView(
|
||||
x, y, horizontalRadius, verticalRadius,
|
||||
canvasId, x, y, horizontalRadius, verticalRadius,
|
||||
);
|
||||
|
||||
if (!templates.length) return;
|
||||
|
@ -154,17 +154,19 @@ export function renderOverlay(
|
|||
* high scale values
|
||||
*/
|
||||
export function renderSmallPOverlay(
|
||||
state,
|
||||
$viewport,
|
||||
view,
|
||||
scale,
|
||||
) {
|
||||
if (!templateLoader.ready) return;
|
||||
const { canvasId } = state.canvas;
|
||||
const [x, y] = view;
|
||||
const { width, height } = $viewport;
|
||||
const horizontalRadius = width / 2 / scale;
|
||||
const verticalRadius = height / 2 / scale;
|
||||
const templates = templateLoader.getTemplatesInView(
|
||||
x, y, horizontalRadius, verticalRadius,
|
||||
canvasId, x, y, horizontalRadius, verticalRadius,
|
||||
);
|
||||
|
||||
if (!templates.length) return;
|
||||
|
|
|
@ -79,10 +79,11 @@ class TemplateLoader {
|
|||
return null;
|
||||
}
|
||||
|
||||
getColorOfPixel(x, y) {
|
||||
getColorOfPixel(canvasId, x, y) {
|
||||
const templatesInView = this.#store.getState().templates.list
|
||||
.filter((template) => (
|
||||
template.enabled && template.x < x && template.y < y
|
||||
template.enabled && template.canvasId === canvasId
|
||||
&& template.x < x && template.y < y
|
||||
&& template.x + template.width > x
|
||||
&& template.y + template.height > y
|
||||
));
|
||||
|
@ -101,14 +102,15 @@ class TemplateLoader {
|
|||
return null;
|
||||
}
|
||||
|
||||
getTemplatesInView(x, y, horizontalRadius, verticalRadius) {
|
||||
getTemplatesInView(canvasId, x, y, horizontalRadius, verticalRadius) {
|
||||
const topX = x - horizontalRadius;
|
||||
const topY = y - verticalRadius;
|
||||
const bottomX = x + horizontalRadius;
|
||||
const bottomY = y + verticalRadius;
|
||||
|
||||
return this.#store.getState().templates.list.filter((template) => (
|
||||
template.enabled && template.x < bottomX && template.y < bottomY
|
||||
template.enabled && template.canvasId === canvasId
|
||||
&& template.x < bottomX && template.y < bottomY
|
||||
&& template.x + template.width > topX
|
||||
&& template.y + template.height > topY
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue
Block a user