Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds linear and radial gradients as fill paint of shapes. Closes #16.
Changes
Style::parseColor()returns a paint reference forurl(#id), with the fallback color if any.Document::getGradient()resolves a reference, includinghrefinheritance and stop styles from attributes, style sheets andstyle. Gradients are collected in a separate pass over the file, because they can be defined after the element that uses them.Shaperesolves the geometry:gradientUnits,gradientTransform,spreadMethod, lengths with units, focal point.SurfaceCpdf::fillGradient()clips to the path and paints the gradient. The path is recorded to get its bounding box and to draw it again for the stroke.Cpdfgetsgradient()andclip(), the same code as in Supportlinear-gradient()andradial-gradient()as background images (CPDF) dompdf#3822.Limitations
color-interpolation="linearRGB", no references to other files, noSurfacePDFLib.Compatibility
Gradients are painted if the canvas has a
gradient()method. With theCpdfof a dompdf version without it, the average color is used, so both PRs can be merged independently.The existing classes
Tag\LinearGradient,Tag\RadialGradientandGradient\Stopare not used. I left them in place and can remove them if you prefer.Disclaimer:
Most of the code was written by AI (Claude) and reviewed / tested by me.