Repository navigation
Brush: average along the path so slow strokes lose the mouse's pixel staircase - #18
Merged
Merged
Conversation
…staircase A mouse reports whole pixels, so a shallow line arrives as a staircase that repeats every 1 / slope px. The lazy brush filters over only its radius (4 px at the default), so most of each step reached the curve and slow strokes came out faceted. Core.Stroke now takes a span: the brush's path is resampled every step and each point becomes a triangular average of span points either side, shrunk near the ends so the stroke still starts at pointerdown and ends exactly at release. Resampling makes the window a fixed length whatever the event rate. The app uses points 2 screen px apart and a span of 3 x smoothing; smoothing 0 is unchanged. Fewer, evenly spaced points also mean fewer segments per slow stroke than the old 0.5 px minimum step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012G2zCWMtRNnaTYycE9WgpB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A mouse reports whole pixels, so a slow, shallow stroke arrives as a staircase that repeats every 1 / slope px. The lazy brush smooths over only its radius (4 px at the default smoothing). Most of each step therefore reached the curve, and slow strokes came out faceted along their edges.
Change
Core.Stroke(p, radius, step, span)takes a newspan. With it, the brush's path is resampled everystep. Each point is then replaced by a triangular average ofspanpoints on either side. The window shrinks near the ends, so the stroke still starts at the pointerdown point and ends exactly at the release point.brushStroke()inpointer.js), points are 2 screen px apart and the span is 3 × smoothing. Smoothing 0 behaves exactly as before.task.md's brush-smoothing decision is updated.Measurements (simulated whole-pixel mouse input, no benchmark)
How far quantization pushes the curve off the curve drawn from exact input, ends excluded:
The trade-off is that a sharp corner rounds a little more: about 3.4 px from the true corner, versus 2.0 px before.
Tests
test/core.test.js:tail()equalsfinish()npm test: 84 pass.Generated by Claude Code