Why do you want to avoid Metal? Enabling its support is as easy as wrapping your LineGraphShape
s into Group
and modifying it with a drawingGroup()
. Try it out:
...
Group {
let gradient = LinearGradient(
gradient: Gradient(colors: [Color.red, Color.blue]),
startPoint: .leading,
endPoint: .trailing
)
LineGraphShape(points: points[selectedPointType], closePath: true)
.fill(gradient)
LineGraphShape(points: points[selectedPointType], closePath: false)
.stroke(
gradient,
style: .init(
lineWidth: 4.0,
lineCap: .round,
lineJoin: .round,
miterLimit: 10.0
)
)
}
.drawingGroup()
...
Results in a significant performance improvement 🙂