Implement conic-gradient for Cairo graphics backend (printing support)
Categories
(Core :: Graphics, enhancement, P5)
Tracking
()
People
(Reporter: ntim, Unassigned)
References
Details
Attachments
(1 file, 2 obsolete files)
Cairo is used exclusively for printing.
According to jrmuizel, the easiest way to do this is to paint the gradient using a different backend then send the image over to Cairo for printing.
Updated•5 years ago
|
Reporter | ||
Comment 1•5 years ago
|
||
Reporter | ||
Comment 2•5 years ago
|
||
Markus, do you think you could provide a bit of guidance ? I'm not sure this is on the right path. Thanks!
Comment 3•5 years ago
|
||
The approach is looking pretty good to me! The hard part is going to be the computation of the surface bounds, I think. Unless there's some "get current clip extents" helper around.
Comment 4•5 years ago
|
||
Oh, actually, I think it would be best to handle the transform in Skia. For example, let's say you have a 50x50 DrawTargetCairo, set a scale(5) transform on it, and then draw a 10x10 user space conic gradient that should fill the entire DrawTarget. In that case, you'll get blurry rendering if you let Skia render the conic gradient into a 10x10 surface and then scale that surface up to 50x50. It's better if you make a surface of the device space bounds (50x50), pass the current transform to Skia, let Skia fill the 50x50 surface with the correct transform, turn that into a SurfacePattern with the inverse transform set on it, and then draw that SurfacePattern into the DrawTargetCairo so that it's drawn without any transform.
Reporter | ||
Updated•5 years ago
|
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Comment 7•3 years ago
|
||
Cairo can draw conic gradients using the mesh gradient API. See this test case for an example.
https://gitlab.freedesktop.org/cairo/cairo/-/blob/master/test/mesh-pattern-conical.c
This is preferable to embedding an image as it uses vector output on the PS/PDF output.
You just need to ensure there is at least one patch every 90 degrees to maintain a good approximation of a circle as described here.
https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%A9zier-curves
Comment 8•3 years ago
|
||
FWIW, the WebKitGTK/WPE WebKit ports feature an implementation of conic gradients using Cairo as graphics backend. Perhaps that could be useful.
Updated•2 years ago
|
Description
•