Hi , in the following code a fully transparent component is continuously repainted, while another semitransparent component is also continously repainted over the transparent component.
The code should just blink alternatively between dark gray and light gray, but randomly, the shape of the transparent component becomes visible, as can be seen in the attached animated (caution : this is blinking very hard)
class MyGlitchComponent : public Component {
class InvisibleComponent : public Component, public Timer {
public:
InvisibleComponent() {
startTimerHz(60);
}
void timerCallback() override { repaint(); }
};
/** A semi-invisible foreground component */
class AnimatedForeground : public Component, public Timer {
private:
int cnt = 0;
public:
AnimatedForeground() {
startTimerHz(30);
}
void paint(Graphics &g) override {
g.fillAll(Colours::black.withAlpha((cnt & 2) == 0 ? 0.6f : 0.4f));
}
void timerCallback() {
++cnt;
repaint();
}
};
InvisibleComponent invisible;
AnimatedForeground foreground;
public:
MyGlitchComponent () {
addAndMakeVisible(invisible);
addAndMakeVisible(foreground);
setSize(600,600);
}
void resized() override {
invisible.setBounds(getLocalBounds().reduced(getWidth()/4,getHeight()/4));
foreground.setBounds(getLocalBounds());
}
void paint(Graphics &g) {
g.fillAll(Colours::white);
}
};
This is on macOS, with the latest JUCE develop, but it happens also with JUCE 7 so maybe I’m rediscovering something that is already well known ? I see the glitch more often when the window is displayed on my external display than the builtin display of the macbook.
