diff --git a/src/components/Develop.tsx b/src/components/Develop.tsx
index fd70332..4d59c92 100644
--- a/src/components/Develop.tsx
+++ b/src/components/Develop.tsx
@@ -2198,10 +2198,18 @@ export default function Develop({
y: ((f.y - view.y) / view.h) * 100,
};
};
- const xScale = bitmap.width / (frame.w * view.w);
const canvasEl = canvasRef.current;
const canvasW = canvasEl?.clientWidth || 1;
- const canvasH = canvasEl?.clientHeight || 1;
+ // A brush radius is a fraction of the source width, but the
+ // overlay's 100×100 box is stretched over the canvas, so the
+ // two axes are converted separately. Using one frame term for
+ // both (or the canvas aspect) turns the circle into an oval as
+ // soon as the photo is cropped or zoomed.
+ const radiusU = (r: number) => (r * bitmap.width * 100) / (frame.w * view.w);
+ const radiusV = (r: number) => (r * bitmap.width * 100) / (frame.h * view.h);
+ /** Brush diameter in canvas pixels, for the stroke preview. */
+ const diameterPx = (r: number) => (r * 2 * bitmap.width * canvasW) / (frame.w * view.w);
+ const feather = Math.max(0, Math.min(1, activeComponent.feather / 100));
const strokes = localDraft
? [...activeComponent.brush.strokes, localDraft]
: activeComponent.brush.strokes;
@@ -2211,15 +2219,25 @@ export default function Develop({
strokes.map((stroke, i) => {
if (!stroke.points.length) return null;
const points = stroke.points.map(marker).map((p) => `${p.x},${p.y}`).join(' ');
- const width = Math.max(1, stroke.size * 2 * canvasW);
+ const width = Math.max(1, diameterPx(stroke.size));
+ const core = Math.max(1, width * (1 - feather));
return (
-
+
+ {core < width - 0.5 && (
+
+ )}
+
+
);
})}
{activeComponent.kind === 'radial' && (() => {
@@ -2266,16 +2284,34 @@ export default function Develop({
);
})()}
- {activeComponent.kind === 'brush' && localHover && !localDrag.current && (
-
- )}
+ {activeComponent.kind === 'brush' && localHover && !localDrag.current && (() => {
+ const c = marker(localHover);
+ const r = localRadius();
+ // Feather is the soft band inside the rim, so the inner
+ // ring marks where the dab is still at full strength.
+ return (
+
+
+ {feather > 0.02 && (
+
+ )}
+
+ );
+ })()}
);
})()}
diff --git a/src/gl/masks.test.ts b/src/gl/masks.test.ts
index d66aab3..bb93483 100644
--- a/src/gl/masks.test.ts
+++ b/src/gl/masks.test.ts
@@ -1,7 +1,22 @@
import { describe, expect, it } from 'vitest';
-import { blendCoverage } from './masks';
+import { blendCoverage, maskSize } from './masks';
/** Coverage values are 0–1 inside the baker, which this keeps readable. */
+describe('mask texture size', () => {
+ it('keeps square mask pixels so a round brush stays round', () => {
+ const tall = maskSize(3000, 9000);
+ expect(tall.h).toBeLessThanOrEqual(1400);
+ expect(tall.w / tall.h).toBeCloseTo(1 / 3, 2);
+ const wide = maskSize(15000, 1000);
+ expect(wide.h).toBeGreaterThanOrEqual(120);
+ expect(wide.w / wide.h).toBeCloseTo(15, 1);
+ });
+
+ it('uses the full width for a normal photo', () => {
+ expect(maskSize(3464, 5202)).toEqual({ w: 800, h: 1201 });
+ });
+});
+
describe('mask group compositing', () => {
it('starts a group with the first shape whatever its mode says', () => {
expect(blendCoverage(0, 0.6, 'subtract', true)).toBe(0.6);
diff --git a/src/gl/masks.ts b/src/gl/masks.ts
index 149d5e1..c56d7dd 100644
--- a/src/gl/masks.ts
+++ b/src/gl/masks.ts
@@ -211,9 +211,26 @@ export function blendCoverage(
return Math.max(acc, value);
}
+/**
+ * Mask texture size. Pixels are square, so both dimensions scale together with
+ * the source: clamping only the height would squeeze every round dab into an
+ * ellipse on tall or wide frames, so the width shrinks instead.
+ */
+export function maskSize(srcW: number, srcH: number) {
+ const safeW = Math.max(1, srcW);
+ const safeH = Math.max(1, srcH);
+ let w = 800;
+ let h = Math.round((w * safeH) / safeW);
+ const limit = h > 1400 ? 1400 : h < 120 ? 120 : 0;
+ if (limit) {
+ h = limit;
+ w = Math.max(160, Math.round((h * safeW) / safeH));
+ }
+ return { w, h: Math.max(1, h) };
+}
+
export function buildLocalMasks(layers: LocalLayer[], srcW: number, srcH: number): PackedMasks {
- const w = 800;
- const h = Math.max(120, Math.min(1400, Math.round((w * Math.max(1, srcH)) / Math.max(1, srcW))));
+ const { w, h } = maskSize(srcW, srcH);
const out = new Uint8Array(w * h * 4);
const out2 = new Uint8Array(w * h * 4);
const count = Math.min(MAX_LOCAL_LAYERS, layers.length);
diff --git a/src/styles.css b/src/styles.css
index 4b843dd..d10bfe9 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -4661,6 +4661,15 @@ figcaption {
stroke: rgba(255, 92, 92, 0.4);
}
+/* The soft band of the feather, drawn under the solid core. */
+.local-brush.band {
+ stroke: rgba(240, 170, 80, 0.14);
+}
+
+.local-brush.band.erase {
+ stroke: rgba(255, 92, 92, 0.13);
+}
+
.local-outline,
.local-line {
fill: none;
@@ -4686,6 +4695,12 @@ figcaption {
stroke-dasharray: 3 3;
}
+/* Marks where the feather band starts, mirroring the baked mask. */
+.local-cursor.inner {
+ stroke: rgba(240, 174, 85, 0.5);
+ stroke-dasharray: 2 4;
+}
+
.local-list {
display: flex;
flex-direction: column;