Skip to content

Preserve straight color channels in translucent SVG paints - #199

Open
AmanBoronbaev wants to merge 1 commit into
llgcode:masterfrom
AmanBoronbaev:svg-straight-color-channels
Open

AmanBoronbaev wants to merge 1 commit into
llgcode:masterfrom
AmanBoronbaev:svg-straight-color-channels

Conversation

@AmanBoronbaev

Copy link
Copy Markdown

Go exposes premultiplied components through color.Color.RGBA(). Writing those numbers into CSS rgba() applied the alpha a second time when the SVG was rendered. Half-transparent red became visibly darker.

Convert the paint to color.NRGBA before serializing the channels. The regression exercises both fill and stroke through a graphic context, with straight and premultiplied input colors. I also rasterized an exported rectangle with librsvg and checked the center pixel: RGBA (255, 0, 0, 128).

The SVG package passed with the race detector. The repository-wide run reported the two existing raster bug-exposure tests for #181 and #155.

AI assistance: OpenAI Codex wrote the fix and tests and checked the rendered pixel.

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