Melatonin Blur is a batteries-included, cross-platform CPU blur and shadow compositing library for the JUCE C++ framework.
Batteries-included means it aims to give you everything out of the box:
- ๐ฉโ๐จ Figma/CSS-accurate drop and inner shadows on paths
- ๐ Drop and Inner Text shadows
- ๐ ๐ผ Supports both filled and stroked paths
- ๐ ARGB image blurs
- ๐ Fast! (see benchmarks)
- ๐ Retina-friendly (context scale-aware)
- ๐ฐ Trivial to layer multiple shadows
- โ๏ธ Behind-the-scenes multi-layer caching
- ๐ Debug optimized for high quality of life
- ๐ค Over 1000 correctness tests passing on macOS/windows
- ๐ Compatible down to macOS 10.13 (progressive speedups on recent versions)
The goal: modern vector interfaces in JUCE (100s of shadows) without having to resort to deprecated solutions with lower quality of life (looking at you, OpenGL on macOS!).
Melatonin Blur provides a 10-30x speedup over using Stack Blur alone.
On macOS, it depends on the built-in Accelerate framework.
On Windows, it optionally depends on the Intel IPP library. If IPP is not present, it will fall back to a JUCE FloatVectorOperations implementation for single channel (shadows, etc) and Gin’s Stack Blur for ARGB.
On all platforms, if a faster algorithm isn’t available, it will fall back to an internal version of Roland Rabien’s Stack Blur from his awesome repo Gin.
Interested in how CPU blurring works? I wrote an in-depth article about re-implementing Stack Blur 15+ times.
Leave a Reply