fix mask brush and add full resolution img2img
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
parent
9c0f6df20b
commit
fe4b50cb8d
2 changed files with 31 additions and 4 deletions
|
@ -227,6 +227,7 @@ const dream_img2img_callback = (evn, state) => {
|
|||
}
|
||||
|
||||
request.mask = auxCanvas.toDataURL();
|
||||
request.inpaint_full_res = state.fullResolution;
|
||||
|
||||
// Dream
|
||||
dream(bb.x, bb.y, request, {method: "img2img", stopMarching, bb});
|
||||
|
@ -336,6 +337,7 @@ const img2imgTool = () =>
|
|||
init: (state) => {
|
||||
state.snapToGrid = true;
|
||||
state.invertMask = true;
|
||||
state.fullResolution = false;
|
||||
|
||||
state.denoisingStrength = 0.7;
|
||||
|
||||
|
@ -404,6 +406,13 @@ const img2imgTool = () =>
|
|||
"Invert Mask"
|
||||
).label;
|
||||
|
||||
// Inpaint Full Resolution Checkbox
|
||||
state.ctxmenu.fullResolutionLabel = _toolbar_input.checkbox(
|
||||
state,
|
||||
"fullResolution",
|
||||
"Inpaint Full Resolution"
|
||||
).label;
|
||||
|
||||
// Denoising Strength Slider
|
||||
state.ctxmenu.denoisingStrengthSlider = _toolbar_input.slider(
|
||||
state,
|
||||
|
@ -429,6 +438,8 @@ const img2imgTool = () =>
|
|||
menu.appendChild(document.createElement("br"));
|
||||
menu.appendChild(state.ctxmenu.invertMaskLabel);
|
||||
menu.appendChild(document.createElement("br"));
|
||||
menu.appendChild(state.ctxmenu.fullResolutionLabel);
|
||||
menu.appendChild(document.createElement("br"));
|
||||
menu.appendChild(state.ctxmenu.denoisingStrengthSlider);
|
||||
menu.appendChild(state.ctxmenu.borderMaskSlider);
|
||||
},
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
const _mask_brush_draw_callback = (evn, state) => {
|
||||
if (evn.initialTarget.id === "overlayCanvas") {
|
||||
if (
|
||||
(evn.initialTarget && evn.initialTarget.id === "overlayCanvas") ||
|
||||
(!evn.initialTarget && evn.target.id === "overlayCanvas")
|
||||
) {
|
||||
maskPaintCtx.globalCompositeOperation = "source-over";
|
||||
maskPaintCtx.strokeStyle = "#FF6A6A";
|
||||
|
||||
maskPaintCtx.lineWidth = state.brushSize;
|
||||
maskPaintCtx.beginPath();
|
||||
maskPaintCtx.moveTo(evn.px, evn.py);
|
||||
maskPaintCtx.moveTo(
|
||||
evn.px === undefined ? evn.x : evn.px,
|
||||
evn.py === undefined ? evn.y : evn.py
|
||||
);
|
||||
maskPaintCtx.lineTo(evn.x, evn.y);
|
||||
maskPaintCtx.lineJoin = maskPaintCtx.lineCap = "round";
|
||||
maskPaintCtx.stroke();
|
||||
|
@ -13,13 +19,19 @@ const _mask_brush_draw_callback = (evn, state) => {
|
|||
};
|
||||
|
||||
const _mask_brush_erase_callback = (evn, state) => {
|
||||
if (evn.initialTarget.id === "overlayCanvas") {
|
||||
if (
|
||||
(evn.initialTarget && evn.initialTarget.id === "overlayCanvas") ||
|
||||
(!evn.initialTarget && evn.target.id === "overlayCanvas")
|
||||
) {
|
||||
maskPaintCtx.globalCompositeOperation = "destination-out";
|
||||
maskPaintCtx.strokeStyle = "#FFFFFFFF";
|
||||
|
||||
maskPaintCtx.lineWidth = state.brushSize;
|
||||
maskPaintCtx.beginPath();
|
||||
maskPaintCtx.moveTo(evn.px, evn.py);
|
||||
maskPaintCtx.moveTo(
|
||||
evn.px === undefined ? evn.x : evn.px,
|
||||
evn.py === undefined ? evn.y : evn.py
|
||||
);
|
||||
maskPaintCtx.lineTo(evn.x, evn.y);
|
||||
maskPaintCtx.lineJoin = maskPaintCtx.lineCap = "round";
|
||||
maskPaintCtx.stroke();
|
||||
|
@ -38,14 +50,18 @@ const maskBrushTool = () =>
|
|||
// Start Listeners
|
||||
mouse.listen.canvas.onmousemove.on(state.movecb);
|
||||
mouse.listen.canvas.onwheel.on(state.wheelcb);
|
||||
mouse.listen.canvas.left.onpaintstart.on(state.drawcb);
|
||||
mouse.listen.canvas.left.onpaint.on(state.drawcb);
|
||||
mouse.listen.canvas.right.onpaintstart.on(state.erasecb);
|
||||
mouse.listen.canvas.right.onpaint.on(state.erasecb);
|
||||
},
|
||||
(state, opt) => {
|
||||
// Clear Listeners
|
||||
mouse.listen.canvas.onmousemove.clear(state.movecb);
|
||||
mouse.listen.canvas.onwheel.clear(state.wheelcb);
|
||||
mouse.listen.canvas.left.onpaintstart.clear(state.drawcb);
|
||||
mouse.listen.canvas.left.onpaint.clear(state.drawcb);
|
||||
mouse.listen.canvas.right.onpaintstart.clear(state.erasecb);
|
||||
mouse.listen.canvas.right.onpaint.clear(state.erasecb);
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue