JUCE
JUCE copied to clipboard
[Bug]: Incorrect radial gradient (CoreGraphics)
juce::ColourGradient with isRadial set to true doesn't blend RGB components correctly when using CoreGraphics.
Code
void MainComponent::paint (juce::Graphics& g)
{
g.fillAll(juce::Colours::black);
g.setGradientFill({
juce::Colours::white, {0.0f, 0.0f},
juce::Colours::red.withAlpha(0.0f), {0.0f, (float)getHeight()}
, false
});
g.fillRect(getLocalBounds().removeFromLeft(getWidth() / 2));
g.setGradientFill({
juce::Colours::white, {(float)getWidth()*0.5f, 0.0f},
juce::Colours::red.withAlpha(0.0f), {(float)getWidth()*0.5f, (float)getHeight()}
, true
});
g.fillRect(getLocalBounds().removeFromRight(getWidth() / 2));
}
Result
Apparently, radial gradients only mix alpha values when one of the colour stops is transparent.
Expected behaviour
All components of the colour stops should mix and the transparent colour should be visible in the interpolation. (In the provided example code, the gradients should be seamless)
Observations
- Software renderer works as expected.
- The very first frame of the window is actually correct, only to get immediately redrawn as shown.
Version
JUCE v8.0.8
Operating systems
macOS Sonoma 14.5 (23F79)
Architectures
Arm64/aarch64
Testing on the develop branch
I have tested against the develop branch
Code of Conduct
- [x] I agree to follow the Code of Conduct