Skip to content

renderText: the outline doesn't show through translucent text - #77

Merged
matmen merged 1 commit into
masterfrom
stroke-outside
Oct 16, 2026
Merged

matmen merged 1 commit into
masterfrom
stroke-outside

Conversation

@matmen

@matmen matmen commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Fixes the outline of Image.renderText (strokeWidth): it showed through translucent text, so a 50%-alpha black text color with an orange stroke came out brown inside the letters, and the emoji came out tinted orange.

Cause

The stroke is a distance field around the glyphs, so it also covers the glyphs themselves. It was drawn underneath them weighted by one minus the fill's alpha, so with a translucent text color it showed through.

Fix

The stroke is now weighted by one minus the glyphs' coverage (text and color glyphs) instead of the fill's alpha.

  • For opaque text the formula is identical, so all existing stroke targets (effects, options, regressions) pass unchanged.
  • For translucent text the stroke shows only around the glyphs.

Test

tests/regressions.js checks that pixels fully covered by translucent text keep exactly the text color when a stroke is added. The test fails on master (483 of 483 pixels tinted) and passes here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ

The stroke covers the glyphs as well (it's a distance field from them), and
was drawn under them with one minus the fill's alpha: with a translucent
text color it showed through. It's now masked by the glyphs' coverage
(text and color glyphs), which is the same for opaque text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
@matmen
matmen merged commit 7b94bf8 into master Oct 16, 2026
13 checks passed
@matmen
matmen deleted the stroke-outside branch October 16, 2026 20:23
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