Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions celstomp/celstomp-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
bctx.fillRect(0, 0, contentW, contentH);
bctx.strokeRect(0, 0, contentW, contentH);
drawRectSelectionOverlay(fxctx);
drawLineToolPreview(fxctx);
}

function onionCompositeOperation() {
Expand Down Expand Up @@ -404,6 +405,9 @@
function clearFx() {
fxctx.setTransform(1, 0, 0, 1, 0, 0);
fxctx.clearRect(0, 0, fxCanvas.width, fxCanvas.height);
setTransform(fxctx);
drawRectSelectionOverlay(fxctx);
drawLineToolPreview(fxctx);
}

function wireBrushButtonRightClick() {
Expand Down
16 changes: 16 additions & 0 deletions celstomp/css/components/tools.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@
cursor: pointer;
}

#islandToolsSlot #toolSeg > label svg {
width: 20px;
height: 20px;
color: rgba(255,255,255,0.85);
position: relative;
z-index: 1;
}

#islandToolsSlot #toolSeg > label:has(svg) {
background-image: none;
}

#islandToolsSlot #toolSeg > label:has(svg)::before {
display: none;
}

#islandToolsSlot #toolSeg > label::before{
content: "";
width: 20px;
Expand Down
51 changes: 51 additions & 0 deletions celstomp/js/input/pointer-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ let brushSize = 3;
let autofill = false;

let trailPoints = [];
let lineToolStart = null;
let lineToolPreview = null;

function pressure(e) {
const pid = Number.isFinite(e?.pointerId) ? e.pointerId : -1;
Expand Down Expand Up @@ -338,6 +340,17 @@ function startStroke(e) {
startPan(e);
return;
}
if (tool === "line") {
isDrawing = true;
const hex = colorToHex(currentColor);
strokeHex = activeLayer === LAYER.FILL ? fillWhite : hex;
activeSubColor[activeLayer] = strokeHex;
ensureSublayer(activeLayer, strokeHex);
renderLayerSwatches(activeLayer);
lineToolStart = { x, y };
lineToolPreview = { x, y };
return;
}
if (activeLayer === PAPER_LAYER) {
return;
}
Expand Down Expand Up @@ -404,6 +417,11 @@ function continueStroke(e) {
};
return;
}
if (tool === "line") {
lineToolPreview = { x, y };
queueRenderAll();
return;
}
if (tool === "fill-eraser" || tool === "fill-brush") {
fxTransform();
fxStamp1px(lastPt.x, lastPt.y, x, y);
Expand Down Expand Up @@ -474,6 +492,25 @@ function endStroke() {
stabilizedPt = null;
return;
}
if (tool === "line" && lineToolStart && lineToolPreview) {
const hex = strokeHex || activeSubColor?.[activeLayer] || colorToHex(currentColor);
const off = getFrameCanvas(activeLayer, currentFrame, hex);
const ctx = off.getContext("2d");
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.lineWidth = brushSize;
ctx.strokeStyle = hex;
ctx.beginPath();
ctx.moveTo(lineToolStart.x, lineToolStart.y);
ctx.lineTo(lineToolPreview.x, lineToolPreview.y);
ctx.stroke();
markFrameHasContent(activeLayer, currentFrame, hex);
lineToolStart = null;
lineToolPreview = null;
queueRenderAll();
updateTimelineHasContent(currentFrame);
return;
}
if (tool === "lasso-erase" && lassoActive) {
lassoActive = false;
applyLassoErase();
Expand Down Expand Up @@ -843,6 +880,20 @@ function drawRectSelectionOverlay(ctx) {
ctx.strokeRect(rectSelection.x, rectSelection.y, rectSelection.w, rectSelection.h);
ctx.restore();
}
function drawLineToolPreview(ctx) {
if (!lineToolStart || !lineToolPreview) return;
ctx.save();
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.lineWidth = brushSize;
ctx.strokeStyle = currentColor;
ctx.globalAlpha = 0.5;
ctx.beginPath();
ctx.moveTo(lineToolStart.x, lineToolStart.y);
ctx.lineTo(lineToolPreview.x, lineToolPreview.y);
ctx.stroke();
ctx.restore();
}
function beginRectSelect(e) {
if (activeLayer === PAPER_LAYER) return;
const pos = getCanvasPointer(e);
Expand Down
4 changes: 2 additions & 2 deletions celstomp/js/tools/brush-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ function getBrushSizeForPreview(toolKind) {
function updateBrushPreview() {
if (!_brushPrevEl || !_brushPrevCanvas) return;
const toolKind = getActiveToolKindForPreview();
const isBrush = toolKind === "brush";
const showForTools = toolKind === "brush" || toolKind === "eraser" || toolKind === "line";
const isEraser = toolKind === "eraser";
if (!isBrush && !isEraser) {
if (!showForTools) {
_brushPrevEl.style.display = "none";
return;
}
Expand Down
30 changes: 19 additions & 11 deletions celstomp/js/ui/interaction-shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,13 @@ function wireKeyboardShortcuts() {
const toolByKey = {
1: "brush",
2: "eraser",
3: "fill-brush",
4: "fill-eraser",
5: "lasso-fill",
6: "lasso-erase",
7: "rect-select",
8: "eyedropper"
3: "line",
4: "fill-brush",
5: "fill-eraser",
6: "lasso-fill",
7: "lasso-erase",
8: "rect-select",
9: "eyedropper"
};
document.addEventListener("keydown", e => {
if (e.defaultPrevented) return;
Expand Down Expand Up @@ -690,42 +691,49 @@ function onWindowKeyDown(e) {
});
}
if (isDigit(3)) {
e.preventDefault();
pickTool({
id: "tool-line",
value: "line"
});
}
if (isDigit(4)) {
e.preventDefault();
pickTool({
id: "tool-fillbrush",
value: "fill-brush"
});
}
if (isDigit(4)) {
if (isDigit(5)) {
e.preventDefault();
pickTool({
id: "tool-filleraser",
value: "fill-eraser"
});
}
if (isDigit(5)) {
if (isDigit(6)) {
e.preventDefault();
pickTool({
id: "tool-lassoFill",
value: "lasso-fill"
});
}
if (isDigit(6)) {
if (isDigit(7)) {
e.preventDefault();
pickTool({
id: "tool-lassoErase",
altIds: [ "tool-lassoerase", "tool-lasso-erase" ],
value: "lasso-erase"
});
}
if (isDigit(7)) {
if (isDigit(8)) {
e.preventDefault();
pickTool({
id: "tool-rectSelect",
value: "rect-select"
});
}
if (isDigit(8)) {
if (isDigit(9)) {
e.preventDefault();
pickTool({
id: "tool-eyedropper",
Expand Down
8 changes: 7 additions & 1 deletion celstomp/js/ui/ui-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const tools = [
{ id: 'tool-brush', val: 'brush', label: 'Brush', checked: true },
{ id: 'tool-eraser', val: 'eraser', label: 'Eraser' },
{ id: 'tool-line', val: 'line', label: 'Line', icon: '<svg viewBox="0 0 24 24" width="18" height="18"><line x1="4" y1="20" x2="20" y2="4" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>' },
{ id: 'tool-fillbrush', val: 'fill-brush', label: 'Fill Brush' },
{ id: 'tool-filleraser', val: 'fill-eraser', label: 'Eraser Fill' },
{ id: 'tool-lassoFill', val: 'lasso-fill', label: 'Lasso Fill' },
Expand All @@ -27,7 +28,12 @@
const lbl = document.createElement('label');
lbl.htmlFor = t.id;
lbl.dataset.tool = t.val;
lbl.textContent = t.label;
lbl.setAttribute('aria-label', t.label);
if (t.icon) {
lbl.innerHTML = t.icon;
} else {
lbl.textContent = t.label;
}

if (t.val === 'brush') lbl.id = 'toolBrushLabel';
if (t.val === 'eraser') lbl.id = 'toolEraserLabel';
Expand Down
13 changes: 7 additions & 6 deletions celstomp/parts/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ document.getElementById('part-modals').innerHTML = `
<h4>Tools</h4>
<div class="shortcutRow"><kbd>1</kbd><span>Brush</span></div>
<div class="shortcutRow"><kbd>2</kbd><span>Eraser</span></div>
<div class="shortcutRow"><kbd>3</kbd><span>Fill Brush</span></div>
<div class="shortcutRow"><kbd>4</kbd><span>Fill Eraser</span></div>
<div class="shortcutRow"><kbd>5</kbd><span>Lasso Fill</span></div>
<div class="shortcutRow"><kbd>6</kbd><span>Lasso Erase</span></div>
<div class="shortcutRow"><kbd>7</kbd><span>Rect Select</span></div>
<div class="shortcutRow"><kbd>8</kbd><span>Eyedropper</span></div>
<div class="shortcutRow"><kbd>3</kbd><span>Line</span></div>
<div class="shortcutRow"><kbd>4</kbd><span>Fill Brush</span></div>
<div class="shortcutRow"><kbd>5</kbd><span>Fill Eraser</span></div>
<div class="shortcutRow"><kbd>6</kbd><span>Lasso Fill</span></div>
<div class="shortcutRow"><kbd>7</kbd><span>Lasso Erase</span></div>
<div class="shortcutRow"><kbd>8</kbd><span>Rect Select</span></div>
<div class="shortcutRow"><kbd>9</kbd><span>Eyedropper</span></div>
</div>
<div class="shortcutSection">
<h4>Navigation</h4>
Expand Down