I’m trying to make sense of the ColourGradient class, but I’m going round in circles.
If I want to use a ColourGradient as a brush for a Graphics::fillPath() or Graphics::fillRect() operation, what do I need to do?
Let’s say I have:
ColourGradient cg;
cg.addColour(0, Colours::white);
cg.addColour(0.5f, Colours::red);
cg.addColour(1.0f, Colours::black);
GradientBrush gb(cg);
g.setBrush(&gb);
g.fillRect(0, 0, width, height);
assuming g is my current Graphics context, and width and height are the component size.
This doesn’t work. I guess I need to scale the ColourGradient, but I’ve tried assigning an affine transform to cg.transform, and I’ve tried using gb.applyTransform() but neither seem to be doing anything helpful.
Typically all that I see is the last colour in my gradient list - which would make sense I guess[1] if the gradient was occupying just one pixel.
What am I totally failing to grasp here?
[1] though I’d have thought that the first rasterline would be greyish if so.

