Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep gradient can only easily be implemented in Skia #5

Closed
justvanrossum opened this issue Apr 28, 2021 · 6 comments
Closed

Sweep gradient can only easily be implemented in Skia #5

justvanrossum opened this issue Apr 28, 2021 · 6 comments

Comments

@justvanrossum
Copy link
Collaborator

Skia has GradientShader.MakeSweep but the other libraries and SVG don't have native support for it, as far as I know.

@justvanrossum justvanrossum changed the title Sweep gradient can only eaily be implemented in Skia Sweep gradient can only easily be implemented in Skia Apr 28, 2021
@justvanrossum
Copy link
Collaborator Author

(FWIW, PaintSweepGradient has now been implemented in the Skia backend.)

@horasio
Copy link
Contributor

horasio commented Apr 30, 2021

For the other backend/canvases, we can probably do an approximation with a triangle fan (say ≈360 triangles), with a constant color in each triangle. Generate triangle -> clip/cull against clip-extent -> draw.
Would that be useful?
Could also be a linear gradient in each triangle, but i'm not sure it would look good. Worth a try anyway.

@horasio
Copy link
Contributor

horasio commented Apr 30, 2021

In fact, mesh patterns seems the way to go, in order to get better approx.
Let me experiment...

@justvanrossum
Copy link
Collaborator Author

justvanrossum commented Apr 30, 2021

Ah great, I see Cairo supports mesh patterns, so that may be a good solution there.

For SVG, a triangle approximation is probably best. SVG to me is more a reference, so I wouldn't be bothered much about effiency.

I wonder if for CoreGraphics, CGShading could be an option (although I can imagine that being performant in Python, if that API is supported at all by the Python bridge). I have never used that API.

In the worst case we just don't support sweep gradients in some backends.

@horasio
Copy link
Contributor

horasio commented May 12, 2021

Should that issue be closed?

@justvanrossum
Copy link
Collaborator Author

Yes, let's continue in #17.

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

No branches or pull requests

2 participants