Documentation
¶
Overview ¶
Package depth renders Material-style cast shadows under rectangular regions by composing linear gradients.
A shadow is a soft black fringe around a "shadow rectangle" — the caller's bounds shifted downward by half the elevation extent — to approximate light from above. The geometry mirrors github.com/vibrantgio/pulse/glow.Halo but with two differences:
- The shadow rectangle's interior is filled at the peak alpha too, so the strip extending below bounds stays visible once the caller paints their foreground on top.
- Nothing about the colour is a parameter. It is a fixed key-shadow black at a fixed peak alpha, and neither varies with the elevation level — only the geometry does.
Extent (the gradient's falloff distance) and offset (the downward shift of the shadow rectangle) both follow the level: extent is the level's dp value from tokens.Elevation converted to pixels through gtx.Metric, and offset is half of that. tokens.Level0 — and any level whose dp rounds to zero pixels at the current density — paints nothing at all.
Three things a caller trips on ¶
The interior fill is a hard rectangle. Shadow paints before the foreground and the caller draws over it, so that fill is normally hidden — but a foreground with rounded corners does not hide it, and the fill's four square corners show through the rounding as dark wedges. Every consumer of this package in the organization paints a rounded rectangle (cadence/card, cadence/toast, workbench/mindchat), so that is the default outcome rather than an edge case.
There is no opacity parameter. A shadow that has to fade with the surface it sits under needs the caller to wrap the call in a paint.PushOpacity layer, which is what cadence/toast does to keep the shadow from outliving a toast's fade.
The black is not a token role, so it does not follow the theme. The same call separates a surface strongly on a light background and barely at all on a dark one; a dark theme that wants visible elevation needs something other than this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Shadow ¶
Shadow paints a Material-style cast shadow under bounds onto gtx.Ops at the given elevation level. The shadow is biased downward to approximate light from above.
At tokens.Level0 (and any level whose dp value rounds to zero pixels at the current metric) the function is a no-op.
Types ¶
This section is empty.