Float Constructors and Parameters

As of version 1.4, all constructors and setters support float and double parameters.

Stack Blur is inherently an integer-pixel calculation. For now, floats and doubles are rounded with juce::roundToInt.

Constructors

// rounds down, creates black shadow with radius 1
melatonin::DropShadow shadow = { juce::Colours::black, 1.3f };

// rounds up to int radius of 2
shadow.setRadius (1.6f); 

// creates a black shadow with radius 1 and spread 1
melatonin::DropShadow shadow = { juce::Colours::black, 1.0, { 0, 0 }, 0.6f };

Setters

There is feature parity with integer setters — all varieties of methods are supported:

// x,y float
shadow.setOffset (1.f, 2.f);

// x,y double
shadow.setOffset (1.0, 2.0);

// via juce::Point
juce::Point floatPoint { 2.f, 2.f };
shadow.setOffset (floatPoint);

// via initializer list
shadow.setOffset ( { 1.4f, 1.4f });

Let me know (comment here or open an issue on GitHub) if you care about float-accurate shadows. There’s work that can be done in the compositing step to approximate float shadows. Float offsets could be nice too.


Leave a Reply

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