openOutpaint/js/ui/tool/maskbrush.js
Victor Seiji Hariki 250c833895 Added tool menu and migrated image generation ot new input
Also updates a lot of other things (brush size now independent from
scale factor, split some files, and a lot other things; removed erase
safeguard as now erase is supported by undo/redo; tried adding github
prettier autoformatting to pull requests;

may have some other things as well

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>

Former-commit-id: 0ba21f23c69f9dca2c3189a838b945900b01f81d
2022-11-22 19:28:27 -03:00

27 lines
878 B
JavaScript

const mask_brush_draw_callback = (evn, state) => {
if (evn.initialTarget.id === "overlayCanvas") {
maskPaintCtx.globalCompositeOperation = "source-over";
maskPaintCtx.strokeStyle = "#FF6A6A";
maskPaintCtx.lineWidth = state.brushSize;
maskPaintCtx.beginPath();
maskPaintCtx.moveTo(evn.px, evn.py);
maskPaintCtx.lineTo(evn.x, evn.y);
maskPaintCtx.lineJoin = maskPaintCtx.lineCap = "round";
maskPaintCtx.stroke();
}
};
const mask_brush_erase_callback = (evn, state) => {
if (evn.initialTarget.id === "overlayCanvas") {
maskPaintCtx.globalCompositeOperation = "destination-out";
maskPaintCtx.strokeStyle = "#FFFFFFFF";
maskPaintCtx.lineWidth = state.brushSize;
maskPaintCtx.beginPath();
maskPaintCtx.moveTo(evn.px, evn.py);
maskPaintCtx.lineTo(evn.x, evn.y);
maskPaintCtx.lineJoin = maskPaintCtx.lineCap = "round";
maskPaintCtx.stroke();
}
};