Skip to main content

Module layer_shadow

Module layer_shadow 

Source
Expand description

Elevation shadows as Jetpack Compose draws them: Android’s renderer and Compose Multiplatform’s both light a layer from one point above the window and hand the caster to Skia’s SkShadowUtils, which draws an ambient and a spot shadow. The constants below are theirs.

Structs§

LayerShadowGeometry
ShadowHole
The round rect inside a shadow that it leaves undrawn: bounds of the shadow inset by inset, its corners rounded at radius.
ShadowLight
The light elevation shadows are cast by, in the units and coordinates the shadow is collected in.
ShadowRRect
One pass of a shadow as Skia’s ShadowCircularRRectOp draws it: a round rect whose penumbra rises from its outer edge, bounds, toward the umbra umbra_inset in. Corners are fans of triangles whose offsets the GPU interpolates, so a corner is a quarter circle where the umbra meets its radius and a skewed one where the blur is wider. Every length is in the space the shadow is collected in.

Functions§

fan_offset
The length of the offset Skia’s corner fan interpolates at along and across, a point’s distances out from the umbra’s corner toward the two edges, for an umbra inset umbra and a corner radius radius: 0 at the umbra and 1 on the outer edge. The fan’s triangles meet the edge at the umbra line, at umbra - radius along it and at the corner, whose offsets Skia skews when the umbra is deeper than the radius.
layer_shadow_geometry
The ambient and spot passes of layer’s shadow over transformed_bounds with the corners caster rounds it at, lit by light. Matches Skia’s SurfaceDrawContext::drawFastShadow and SkDrawShadowMetrics.
shadow_falloff
Skia’s penumbra falloff at x, the ramp’s coordinate: 0 on the outer edge, 1 where the shadow is whole, read as its table is.