README.md

October 28, 2024 ยท View on GitHub

Figma - 2023-11-09 42@2x

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!).

https://github.com/sudara/melatonin_blur/assets/472/3e1d6c9a-aab9-422f-a262-6b63cbca5b71

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.

Interested in how the blurring works? I wrote an in-depth article about re-implementing Stack Blur 15+ times.

Installation

The docs have outgrown a README file, visit the new documentation

Usage

There's all the usage information you could want over at the official docs

Acknowledgements

  • Mars, for being my reliable rubber duck! Inner Shadow caching and compositing geometry broke my brain.
  • Roland Rabien for JUCE Stack Blur workhorse via Gin.
  • LukeM1 on the forums for figuring out the drawImageAt optimization.
  • Ecstasy on the Discord for the motivation and feedback around stroked paths and default constructors.