It is said that use of Canvas to create complex shapes can provide better performance
in SwiftUI. This article compares performance of scrolling through multiple instances
of the same card pattern created using shape, canvas or image.
I discovered, when playing around with the rounded-corner star shape, that the same
basic shape could be used to create a cog shape. This article demonstrates the
creation of the cog shape and the use of timelineview to animate its rotation in
TimelineView, introduced in iOS 15, can be used to change objects on a canvas over
time. The article takes the star shape defined previously and animates rotating the
star shape on the canvas in a SwiftUI view.
TimelineView was introduced in iOS 15 to control how a view can change over time.
This article takes the heart shape defined previously and animates by changing the
path on the canvas in a SwiftUI view.
The canvas view provides a mechanism to draw in SwiftUI. The canvas takes
GraphicsContext and size as parameters to allow immediate mode drawing within the
containing frame. Here we draw system shapes as well as freeform shapes using path