Skip to content

Commit 03ca079

Browse files
committed
suppress DrawText artifacts on windows
1 parent 8e2aa7a commit 03ca079

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/lib/animation/effect/draw-text.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type GlyphPath = {
6666

6767
const clamp01 = (value: number) => Math.min(1, Math.max(0, value))
6868
const DEFAULT_LAG_RATIO = 0.6
69+
const STROKE_VISIBLE_EPSILON = 1e-4
6970

7071
const resolveTimelineValue = (
7172
source: number | Variable<number> | undefined,
@@ -374,6 +375,8 @@ const renderGlyphSvg = (params: {
374375
outTiming.duration > 0 ? clamp01((frame - outTiming.start) / outTiming.duration) : 0
375376
const progress = outProgress > 0 ? inProgress * (1 - outProgress) : inProgress
376377
const dashOffset = length > 0 ? length * (1 - progress) : 0
378+
// Workaround for Chromium/Skia: stroke-dash can leak a 1px cap at progress=0 on Windows.
379+
const strokeVisible = length > 0 && progress > STROKE_VISIBLE_EPSILON
377380
const fillStart = timing.start + timing.duration + fillDelayFrames
378381
const fillProgress =
379382
resolvedFillColor === "transparent"
@@ -396,6 +399,7 @@ const renderGlyphSvg = (params: {
396399
strokeLinejoin="round"
397400
strokeDasharray={length || 1}
398401
strokeDashoffset={dashOffset}
402+
strokeOpacity={strokeVisible ? 1 : 0}
399403
style={{ opacity: length > 0 ? 1 : 0 }}
400404
/>
401405
)

0 commit comments

Comments
 (0)