gfx/gradient.h
Colour that varies across a shape.
#include <sonore/gfx/gradient.h>- 2types
- 1other declaration
- Guides: The native editor
On this page
Design notes
Every panel, every knob body and every meter in a plugin is a gradient. Flat fills are what makes a generated interface look generated, and a gradient is the cheapest thing that stops it.
Where the interpolation happens
In STRAIGHT alpha, always. Premultiplied is right for compositing and wrong for interpolation: a fade from opaque red to transparent, premultiplied, passes through dark red and then black, because the transparent end's colour channels have already been multiplied to zero. The same fade in straight alpha stays red the whole way and only loses opacity, which is what anyone asking for a fade meant. Premultiplication happens per pixel, after.
Where the coordinates are
A gradient is authored in USER space, next to the rectangle it fills. The rasteriser works in DEVICE space. transformed() moves one to the other once, per fill, rather than inverting a transform per pixel.
Types 2
A colour at a proportion along the gradient. 0 is point1, 1 is point2.
A linear or radial ramp between two points, with any number of stops.
A colour gradient in the shape that matters: two endpoints, a flag for radial, and stops in between. Named constructors for the two cases that are ninety per cent of use, because ColourGradient(a, {0,0}, b, {0,h}, false) is four chances to write the wrong thing.
Enums 1
- enum
enum class GradientSpreadWhat a gradient does past its ends.gfx::GradientSpread · gradient.h:43