Forcing an animation

wondering if anyone has tried this as well.

i have 4 images that change depending on slider value.

trying to force the animation through in case the user or automation stays on the slider transition value 185.

slider = 184:
show image1

slider = 185:
show image2 for 75ms, then show image3 for 75ms, then set slider to 186

slider = 186:
show image4

currently i am using a combination of callAfterDelay and slider.setEnabled.

but i am still able to stop at 185 and see a transition image.

i would also be ok if there was a solution that only used 1 transition image.

i am using maxmspRNBO + juce

Thanks for any help :slight_smile:

void TemplateUI::drawFirstImage(juce::Graphics& g)
{
juce__slider2->setEnabled(false);
ktRect = juce::Rectangle(x+(102/z), y+(((k*2)-90)/z), ktImages[0].getWidth()/z, ktImages[0].getHeight()/z);
g.drawImage(ktImages[0], ktRect);
repaint();
juce::timer::callAfterDelay(75, [this]
{
drawImage1 = false;
drawImage2 = true;
});
}

void TemplateUI::drawSecondImage(juce::Graphics& g)
{
juce__slider2->setEnabled(false);
ktRect2 = juce::Rectangle(x+(104/z), y+(((k*2)-96)/z), ktImages[1].getWidth()/z, ktImages[1].getHeight()/z);
g.drawImage(ktImages[1], ktRect2);
repaint();
juce::timer::callAfterDelay(75, [this]
{
juce__slider2->setEnabled(true);
k = 186;
drawImage1 = true;
drawImage2 = false;
});
}

Totally off topic: can you please edit your post to add three back ticks before and after your code to have it formatted properly?

Or select the code and hit the </> icon in the editor, which does the same thing…
Thanks

1 Like
void TemplateUI::drawFirstImage(juce::Graphics& g)
{
juce__slider2->setEnabled(false);
ktRect = juce::Rectangle(x+(102/z), y+(((k*2)-90)/z), ktImages[0].getWidth()/z, ktImages[0].getHeight()/z);
g.drawImage(ktImages[0], ktRect);
repaint();
juce::timer::callAfterDelay(75, [this]
{
drawImage1 = false;
drawImage2 = true;
});
}

void TemplateUI::drawSecondImage(juce::Graphics& g)
{
juce__slider2->setEnabled(false);
ktRect2 = juce::Rectangle(x+(104/z), y+(((k*2)-96)/z), ktImages[1].getWidth()/z, ktImages[1].getHeight()/z);
g.drawImage(ktImages[1], ktRect2);
repaint();
juce::timer::callAfterDelay(75, [this]
{
juce__slider2->setEnabled(true);
k = 186;
drawImage1 = true;
drawImage2 = false;
});
}