Skip to content

fix: the pencil keeps answering pressure above the neutral point (#338) - #360

Merged
difficcd merged 1 commit into
mainfrom
fix/pencil-pressure-clamp
Oct 1, 2026
Merged

difficcd merged 1 commit into
mainfrom
fix/pencil-pressure-clamp

Conversation

@difficcd

@difficcd difficcd commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Part of #338 — the "pencil pressure is ignored" half. Found by measurement rather than on the device, so it needed no tablet to confirm.

Cause

strokes.ts sized the pencil with 0.65 + 0.35 * Math.min(1, pr * 2). The * 2 is what puts the neutral 0.5 at 1×, which means the clamp bit at exactly neutral — above it, nothing moved. Measured on a straight 24px stroke, as the thickness in pixels:

pressure 0.1 0.25 0.5 0.6 0.75 0.9 1.0
pencil, before 18 20 24 24 24 24 24
pencil, after 18 20 24 26 28 32 34
brush (for scale) 6 12 24 30 36 44 48

Above 0.5 the pencil was byte-for-byte identical at every pressure. A stylus writes well above 0.5, so the whole range a person actually presses in was flat: indistinguishable from having pressure switched off. The brush, sharing the page, doubles over the same span.

Why the change is safe for existing artwork

Strokes are stored as point lists and re-rendered on every paint, so changing this formula changes drawings that already exist. Dropping the clamp only extends the curve past neutral — the value at and below 0.5 is untouched. Verified by rendering to pixels on both revisions and comparing base64:

IDENTICAL mouse        IDENTICAL pen0.25      IDENTICAL pen0.5
IDENTICAL pen0.1       IDENTICAL pen0.4       DIFFERENT pen1.0

A mouse reports no pressure, which reads as the neutral 0.5, so no mouse-drawn stroke moves at all.

The alpha term keeps its clamp

Deliberately, and there is now a comment saying why: the pencil is already fully opaque at neutral, so there is no headroom to press into. Lowering the neutral to make room would re-render every pencil stroke ever drawn, lighter. Above neutral the pencil expresses pressure in its width alone — a real limit, not an oversight, and worth knowing before someone "fixes" it the same way.

Tests

  • a pencil keeps widening above the neutral pressure — the regression test. On main: 0.75 is no thicker than neutral: 24 -> 24.
  • a pencil drawn with no pressure is drawn at the neutral weight — pins the invariant that protects existing artwork: the curve must pass through 1× at 0.5, or every pencil stroke re-renders.

1282 tests pass; npm run check green.

To try

On the tablet, with 필압 on, draw with the pencil pressing lightly and then hard. The line should visibly thicken now; before, anything past a light press was one fixed width. Existing drawings should look exactly as they did.

The other half of #338 — strokes breaking up — is untouched here and still needs the device.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
easy-mv-maker Ready Ready Preview Oct 1, 2026 6:19am UTC

The pencil's width term was `0.65 + 0.35 * Math.min(1, pr * 2)`. The `* 2` is what puts the
neutral 0.5 at 1x, so the clamp bit at exactly neutral: every press above it drew the same
stroke to the pixel. Measured on a straight 24px stroke:

    pressure    0.1  0.25  0.5  0.6  0.75  0.9    1
    before       18    20   24   24    24   24   24
    after        18    20   24   26    28   32   34
    brush         6    12   24   30    36   44   48

A stylus writes well above 0.5, so in practice the pencil behaved as though pressure were
switched off - which is what came in from the tablet. The brush, on the same page, doubles.

Dropping the clamp only extends the curve past neutral, and that matters more than it sounds:
strokes are stored as points and re-rendered on every paint, so a change to this formula
changes artwork already drawn. Checked byte-for-byte against main - mouse, and pen at 0.1,
0.25, 0.4 and 0.5, are all identical images; only a press above neutral differs.

The alpha term keeps its clamp, and a comment now says why: it is already fully opaque at
neutral, so there is no headroom to press into, and lowering the neutral to make room would
re-render every pencil stroke ever drawn, lighter. Above neutral the pencil says pressure in
its width alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@difficcd
difficcd force-pushed the fix/pencil-pressure-clamp branch from 4ee2a85 to d4f5fad Compare October 1, 2026 06:19
@difficcd
difficcd merged commit 905c7bd into main Oct 1, 2026
6 checks passed
@difficcd
difficcd deleted the fix/pencil-pressure-clamp branch October 1, 2026 06:25

This branch was successfully deployed

1 active deployment
Preview — d4f5fade Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant