Gradient Fill - cubic curve?


I followed the gradient code down through some redirections, and found an edge table iterator there, but I can’t tell if it’s doing anything fancier than a linear blend. Is there a way to do a gradient with a cubic curve between/through points?



You can approximate any gradient shape you like by just adding more points to the gradient!


But it would be a straight line gradient in between each point?



Well yes, but that’s like complaining about the fact that bezier curves are drawn by subdividing them into straight lines! As long as you generate enough points, the result will be perfect.


Hmm, yes. I suppose that’s true. I was looking to have a more adjustable system, where I could move one gradient mid-point, not regenerate all the points. If I’m regenerating all the points, then a juce gradient may not do much for me, as I only need to draw this once (then pass to OpenGL as a texture). May as well do it once at a greater bit depth.




You’d only have to write a simple function like “ColourGradient convertToCubic (const ColourGradient&)” that adds extra interpolated points, and call that before drawing a gradient. It’d be as adjustable as you could possibly need (?)


Oh, I’m sure. But I was looking to use a gradient to save time. I’m actually making one off images, that need to be perfect, so I’ll specify a point for every pixel. Don’t really see what a juce gradient adds - it’s just some extra work. It’s easier to make an array of 32-bit floats than to work with an image just to use a gradient class that I still have to feed the right points into (except it’s limited to 8-bit).

No problem.