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§
- Layer
Shadow Geometry - Shadow
Hole - The round rect inside a shadow that it leaves undrawn:
boundsof the shadow inset byinset, its corners rounded atradius. - Shadow
Light - The light elevation shadows are cast by, in the units and coordinates the shadow is collected in.
- ShadowR
Rect - One pass of a shadow as Skia’s
ShadowCircularRRectOpdraws it: a round rect whose penumbra rises from its outer edge,bounds, toward the umbraumbra_insetin. 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
alongandacross, a point’s distances out from the umbra’s corner toward the two edges, for an umbra insetumbraand a corner radiusradius: 0 at the umbra and 1 on the outer edge. The fan’s triangles meet the edge at the umbra line, atumbra - radiusalong 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 overtransformed_boundswith the cornerscasterrounds it at, lit bylight. Matches Skia’sSurfaceDrawContext::drawFastShadowandSkDrawShadowMetrics. - 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.