Animating Shadows with Setters

Starting with version 1.2, caching of the underlying single channel blurs is position, color, offset and opacity agnostic.

Translation: you can animate these things at 60fps and it’s very cheap. The image is re-composited, but there is no expensive blur recalculation.

This is fantastic for juce::Paths that look the same each paint but move around (such as slider thumbs).

//  "free" operations that reuse the underlying cached blurs
path.translate(10, 0);
shadow.setColor(juce::Colours::red);
shadow.setOffset({ 10, 0 });
shadow.setOpacity(0.5f);

// "expensive", requiring a recalculation of the underlying blur
shadow.setRadius(10);
shadow.setSpread(10);

Leave a Reply

Your email address will not be published. Required fields are marked *