render/background_painter library
Calculator backgrounds from a BackgroundSpec (spec §5.1 Background): solid, linear/radial gradients and overlay patterns.
- Cheap: gradient shaders and pattern pictures are cached per (spec, size) in a small LRU (BackgroundCache); a repaint is one rect draw plus at most one picture draw.
- Legible: inside the display's
textSafeAreathe painter lays the background without its pattern, fading out below it, so nothing busy ever sits behind display text (spec §5.4). The guardrails check display text against every colour stop (and the surface). - Mesh gradients (Liquid Glass) are a base plus soft radial blobs
(glass/mesh_painter.dart) that drift on
driftPeriodMswith the shared AmbientClock (frozen under Reduce Motion). Noise and shader kinds fall back to a linear gradient of their colours until their families ship. - Family scenes (Claymorphism, Y2K / Frutiger Aero, Paper & ink, Cyberpunk, Vaporwave, Bauhaus) each own a BackgroundKind and paint themselves through backgroundScenePainters; they keep the text area calm on their own.
Classes
- BackgroundCache
- Small LRU of gradient shaders and pattern pictures.
- BackgroundPainter
- Paints a BackgroundSpec over the whole canvas.
- BackgroundScene
- What a family scene painter is given (see backgroundScenePainters).
- SpecBackdrop
- The CalcBackdrop for a BackgroundSpec.
Constants
-
backgroundScenePainters
→ const Map<
BackgroundKind, BackgroundScenePainter> - Family scene kind → its painter (each family's render directory).
Functions
-
backdropSceneKind(
CalcBackdrop? backdrop) → BackgroundKind? -
The family scene
backdroppaints (a key of backgroundScenePainters), or null for anything else: no backdrop, a plain colour, gradients, patterns and meshes. Chrome that sits over a scene's art checks it (the toolbar's mode button: Bauhaus's masthead, Vaporwave's sun). -
linearGradientShader(
Size size, List< Color> colors, int angleTenths) → Shader -
A linear gradient across
sizethrough evenly spacedcolors(two or more) atangleTenths(tenths of a degree; 0 = top → bottom, turning clockwise), corner to corner along that direction: the generic background gradient, for family scenes too.
Typedefs
- BackgroundScenePainter = void Function(Canvas canvas, Size size, BackgroundScene scene)
- Paints one family scene over the whole canvas.