Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/effects2d.h

Blur, drop shadows, rectangle fitting, and the named colours.

#include <sonore/gfx/effects2d.h>
On this page

Design notes

Why these are together

A drop shadow IS a blurred silhouette, so the blur has to exist first. And the other two came out of the same audit for the same reason: both were hand-rolled inside something that needed them -- aspect-preserving fit inside Drawable::draw, thirteen colour names inside the SVG parser -- which is always the sign that a thing belongs somewhere shared.

Types 3

A box blur, run three times, which is a very good Gaussian.

A true Gaussian kernel of radius r costs 2r multiplies per pixel per axis; this costs one add and one subtract per pixel per pass REGARDLESS of radius, because each step only adds the pixel entering the window and subtracts the one leaving. That is what makes a shadow affordable: a radius-16 blur on a 600x400 editor is fifteen million multiply-accumulates the honest way, and under two million adds this way.

A shadow under a shape.

Drawn by rasterising the shape into a scratch bitmap in the shadow's colour, blurring that, and compositing it -- which is what a shadow IS, and is why this needs the blur above rather than a clever approximation.

The scratch is only as big as the shape plus the blur's reach, so a small shadow on a large editor costs a small bitmap.

How one rectangle is placed inside another.

Hand-rolled inside Drawable::draw before this existed, and WaveformView and drawImage want the same rules -- which is what a shared thing is for.

Functions 1

↑↓ to move↵ to openEvery public name in the headers, and every guide