How to draw conic gradient?


Hi !

Does anyone know how to achieve this kind of gradient ? (the gradient part, not the mask part)



Thanks !


Add a gradient to the graphics state and draw?

For your gradient use the isRadial=true and follow the api-docs...



Hi Daniel, thanks for helping :)

I dont want a radial gradient,  I want a linear one, but with a circular shape.


I want this:

not this:



Right, radial != radial. Sorry, my fault... Interesting question though...


Yes ... seems tricky even in an SVG file :/


It doesn't look like JUCE has anything for Conical Gradients.  You might be able to find something on the Web on how you can make one, or how to make something like a color wheel if that's what you're after. 


The only way I can think of doing it in JUCE is by brute force. Convert the X,Y coordinates to radians and in a loop create small gradients and draw the shape piece by piece.



"Conic Gradient", thats the keyword I was missing, thanks !

I'll try to derive a ColourConicalGradient class from ColourGradient, thanks everyone !


This thread just came up.

You might be able to use it to implement what you're wanting, if it's still working. Take a look at the "angle gradient" in that post. It looks like a conical gradient to me.

If you look at the GradientOverlay image, it's doing pretty much exactly what you're wanting.