Skip to content

fix(style): reject translucent gradient stops instead of rendering them opaque#203

Merged
DemchaAV merged 1 commit into
developfrom
fix/gradient-stop-rejects-translucent
Jun 17, 2026
Merged

fix(style): reject translucent gradient stops instead of rendering them opaque#203
DemchaAV merged 1 commit into
developfrom
fix/gradient-stop-rejects-translucent

Conversation

@DemchaAV

Copy link
Copy Markdown
Owner

Why

DocumentPaint gradients render through PDF axial / radial shadings, which
carry no alpha channel. PdfShadingSupport reads only a stop colour's RGB, so a
translucent stop rendered fully opaque with no diagnostic — the silent
wrong-render the codebase otherwise refuses (the SVG reader already rejects
stop-opacity, charts reject NaN series values, etc.).

What changed

DocumentPaint.Stop's compact constructor now rejects a colour with alpha below
255, naming the offending alpha and pointing at the fix (flatten the
transparency into the stop colour, or apply opacity to the whole shape). This
sits next to the offset guard already on the record, and the
DocumentPaint.linear(from, to) two-colour sugar inherits it because it builds
stops. Opaque gradients are unaffected and stay byte-identical.

Binary-compatible: the record signature is unchanged (a behaviour guard, not an
API-shape change), so the japicmp gate stays green.

Verification

  • ./mvnw test -pl . → BUILD SUCCESS, 1392 tests, 0 failures.
  • New DocumentPaintTest pins opaque-accepted, translucent-rejected (rgba
    alpha 0 and withOpacity(0.5)), offset-out-of-range, and the linear sugar
    inheriting the guard.
  • GenerateAllExamples regenerates every example PDF (the gradient-heavy
    feature-catalog / business-report / engine-deck / vector-path included) with
    no rejection — confirming nothing in the suite or examples constructs a
    translucent stop.

Lane: canonical (document.style). No public API-shape change; behaviour guard only.

…em opaque

Gradients render through PDF axial/radial shadings, which carry no alpha
channel, so PdfShadingSupport dropped a stop colour's alpha and a translucent
stop rendered fully opaque with no diagnostic. DocumentPaint.Stop now rejects a
colour with alpha below 255 at construction, naming the offending alpha —
matching the offset guard already on the record and the SVG reader's existing
refusal of stop-opacity. The DocumentPaint.linear(from, to) sugar inherits the
guard. Opaque gradients are unaffected and stay byte-identical.

Tests: DocumentPaintTest pins the opaque / translucent / offset cases and the
linear-sugar path. ./mvnw test -pl . green (1392); all example PDFs regenerate.
@DemchaAV DemchaAV merged commit 516c54d into develop Jun 17, 2026
11 checks passed
@DemchaAV DemchaAV deleted the fix/gradient-stop-rejects-translucent branch June 17, 2026 06:16
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