fix border mask rendering
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
parent
bc19de9c4e
commit
059c0759fe
1 changed files with 36 additions and 34 deletions
|
@ -307,42 +307,44 @@ const img2imgTool = () =>
|
||||||
|
|
||||||
state.mousemovecb = (evn) => {
|
state.mousemovecb = (evn) => {
|
||||||
_reticle_draw(evn, state.snapToGrid);
|
_reticle_draw(evn, state.snapToGrid);
|
||||||
const bb = getBoundingBox(
|
if (evn.target.id === "overlayCanvas") {
|
||||||
evn.x,
|
const bb = getBoundingBox(
|
||||||
evn.y,
|
evn.x,
|
||||||
basePixelCount * scaleFactor,
|
evn.y,
|
||||||
basePixelCount * scaleFactor,
|
basePixelCount * scaleFactor,
|
||||||
state.snapToGrid && basePixelCount
|
basePixelCount * scaleFactor,
|
||||||
);
|
state.snapToGrid && basePixelCount
|
||||||
|
|
||||||
// For displaying border mask
|
|
||||||
const auxCanvas = document.createElement("canvas");
|
|
||||||
auxCanvas.width = bb.w;
|
|
||||||
auxCanvas.height = bb.h;
|
|
||||||
const auxCtx = auxCanvas.getContext("2d");
|
|
||||||
|
|
||||||
if (state.borderMaskSize > 0) {
|
|
||||||
auxCtx.fillStyle = "#FF6A6A50";
|
|
||||||
auxCtx.fillRect(0, 0, state.borderMaskSize, bb.h);
|
|
||||||
auxCtx.fillRect(0, 0, bb.w, state.borderMaskSize);
|
|
||||||
auxCtx.fillRect(
|
|
||||||
bb.w - state.borderMaskSize,
|
|
||||||
0,
|
|
||||||
state.borderMaskSize,
|
|
||||||
bb.h
|
|
||||||
);
|
|
||||||
auxCtx.fillRect(
|
|
||||||
0,
|
|
||||||
bb.h - state.borderMaskSize,
|
|
||||||
bb.w,
|
|
||||||
state.borderMaskSize
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// For displaying border mask
|
||||||
|
const auxCanvas = document.createElement("canvas");
|
||||||
|
auxCanvas.width = bb.w;
|
||||||
|
auxCanvas.height = bb.h;
|
||||||
|
const auxCtx = auxCanvas.getContext("2d");
|
||||||
|
|
||||||
|
if (state.borderMaskSize > 0) {
|
||||||
|
auxCtx.fillStyle = "#FF6A6A50";
|
||||||
|
auxCtx.fillRect(0, 0, state.borderMaskSize, bb.h);
|
||||||
|
auxCtx.fillRect(0, 0, bb.w, state.borderMaskSize);
|
||||||
|
auxCtx.fillRect(
|
||||||
|
bb.w - state.borderMaskSize,
|
||||||
|
0,
|
||||||
|
state.borderMaskSize,
|
||||||
|
bb.h
|
||||||
|
);
|
||||||
|
auxCtx.fillRect(
|
||||||
|
0,
|
||||||
|
bb.h - state.borderMaskSize,
|
||||||
|
bb.w,
|
||||||
|
state.borderMaskSize
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const tmp = ovCtx.globalAlpha;
|
||||||
|
ovCtx.globalAlpha = 0.4;
|
||||||
|
ovCtx.drawImage(auxCanvas, bb.x, bb.y);
|
||||||
|
ovCtx.globalAlpha = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tmp = ovCtx.globalAlpha;
|
|
||||||
ovCtx.globalAlpha = 0.4;
|
|
||||||
ovCtx.drawImage(auxCanvas, bb.x, bb.y);
|
|
||||||
ovCtx.globalAlpha = tmp;
|
|
||||||
};
|
};
|
||||||
state.dreamcb = (evn) => {
|
state.dreamcb = (evn) => {
|
||||||
dream_img2img_callback(evn, state);
|
dream_img2img_callback(evn, state);
|
||||||
|
|
Loading…
Reference in a new issue