How to draw conic gradient?


#1

Hi !

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

 

 

Thanks !


#2

Add a gradient to the graphics state and draw?

http://www.juce.com/doc/classGraphics#a57478bc2496ebb84696e5ba64b455965

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

http://www.juce.com/doc/classColourGradient#a837b0054a74938bf8ea783d5cdd53897

HTH


#3

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:

 


#4

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


#5

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


#6

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. 


#7

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.

Rail


#8

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

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


#9

This thread just came up.

http://www.juce.com/forum/topic/photoshop-layer-effects-juce-controls?page=1

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. 

http://www.juce.com/sites/default/files/AngleGradient.png

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

http://www.juce.com/sites/default/files/GradientOverlay.png