Skip to content

Add a trail option for fading lines - #31

Open
jorgenbruntveit wants to merge 1 commit into
nilbuild:mainfrom
jorgenbruntveit:trailing-ink-fade
Open

jorgenbruntveit wants to merge 1 commit into
nilbuild:mainfrom
jorgenbruntveit:trailing-ink-fade

Conversation

@jorgenbruntveit

Copy link
Copy Markdown

Adds a fifth choice to Settings → Drawing → Lines fade: Trail behind the pen.

What it does

Instead of the whole line fading after a few seconds, an eraser follows the line from where it started, so the line disappears behind the pen while you keep drawing. The eraser moves at a steady speed along the line, so a long line takes longer to go than a short one, however fast it was drawn. Anything drawn within the start delay is never erased, so the end you are drawing stays visible. After you release, the rest of the line is erased at the same speed.

When the option is selected, two more rows appear:

  • Erasing starts: a slider from 0.2 to 2 seconds, counted from the start of each line. Default 0.6 s.
  • Erasing speed: Slow, Medium, Fast or Very fast (800, 1400, 2000 or 3000 pt/s). Default Fast.

Both are cleared by Reset like the other settings. Existing choices behave as before.

How

  • The trail uses strokeStart on the line's CAShapeLayer, so the line is erased smoothly along its exact shape. Removing points from the start instead made the line jump and slightly change shape as it shrank.
  • While drawing, a timer moves the eraser forward and holds it back from the most recent part of the line.
  • When the line ends, the rest runs as one strokeStart animation, and the layer is removed when it finishes.
  • Trail lines are not rasterized, since their visible part keeps changing.
  • Trail behind the pen is stored as fadeSeconds = -1, so the other values keep their meaning. keep now checks for 0 exactly instead of <= 0.

Testing

Built locally and tested on macOS 27.3 with short and long lines, drawn fast and slowly, at different start and speed settings. The pointer and drawing behave as before with the other fade choices.

This touches the same picker as #27, so whichever lands second will need a small merge there.

"Trail behind the pen" erases each line from its start while you draw,
at a steady speed, so long lines take longer to go than short ones.
When it is selected, Settings shows when erasing starts and how fast
it runs.
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