androidx\graphics\graphics-shapes ported to Avalonia.
- Material 3 Expressive Shapes Access the complete set of predefined Material 3 shapes, or customize your own shapes.
- Shape Morphing Create smooth, high-performance animations that morph between any two arbitrary shapes.
- Avalonia Integration:
- Generate standard Avalonia Geometry objects for custom use.
- Use MaterialShapeView to render static shapes.
- Use MorphShapeView to implement morphing animations between two shapes.
RoundedPolygon.ToGeometry() and Morph.ToGeometry(progress) mirror androidx's
compose/material3/internal/ShapeUtil.kt, including its startAngle, repeatPath and
closePath parameters.
Two deviations, both deliberate:
startAngledefaults to0here, not270. Upstream'stoPathis internal and every caller re-centres the result, so its default is harmless there. On a public API a non-zero default would silently rotate — and, since the rotation is about the origin rather than the shape's centre, translate — every shape drawn through it. PassAvaloniaExtensions.StartAngleTopwhen porting material3 drawing code.- The rotation is applied about the origin, exactly as upstream does; the pivot only decides where the first anchor's angle is measured from.
MorphShapeViewbuilds a freshStreamGeometryfor everyProgresschange, i.e. once per frame while morphing. This is not an oversight: Avalonia 12'sStreamGeometryhas no rewind —_strokePathis readonly and re-Open()ing appends — so a geometry cannot be rebuilt in place. Avoiding the per-frame allocation means dropping to a custom draw operation with a reusedSKPath, which trades away the non-Skia backends.
You can explore the capabilities and play with different Material Shapes by building and running the included Gallery App.