3 struct MapStages: View {
5 @Environment(\.colorScheme) var colorScheme
13 MapColor.colorForScheme(colorScheme)
18 ZStack(alignment: .topLeading) {
20 path.addRect(CGRect(x: 0, y: 0, width: w(stages[0]), height: mapSize.height))
21 }.fill(color.stages.i)
24 CGRect(x: w(stages[0]), y: 0, width: w(stages[1]) - w(stages[0]), height: mapSize.height))
25 }.fill(color.stages.ii)
28 CGRect(x: w(stages[1]), y: 0, width: w(stages[2]) - w(stages[1]), height: mapSize.height))
29 }.fill(color.stages.iii)
32 CGRect(x: w(stages[2]), y: 0, width: mapSize.width - w(stages[2]), height: mapSize.height)
34 }.fill(color.stages.iv)
37 path.move(to: CGPoint(x: w(stages[0]), y: 0))
38 path.addLine(to: CGPoint(x: w(stages[0]), y: mapSize.height))
39 path.move(to: CGPoint(x: w(stages[1]), y: 0))
40 path.addLine(to: CGPoint(x: w(stages[1]), y: mapSize.height))
41 path.move(to: CGPoint(x: w(stages[2]), y: 0))
42 path.addLine(to: CGPoint(x: w(stages[2]), y: mapSize.height))
43 path.move(to: CGPoint(x: w(stages[0]), y: 0))
45 }.strokedPath(StrokeStyle(lineWidth: lineWidth, dash: [10.0])).stroke(color.foreground)
49 func w(_ dimension: CGFloat) -> CGFloat {
50 max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
54 struct MapStages_Previews: PreviewProvider {
55 static var previews: some View {
57 mapSize: CGSize(width: 200.0, height: 200.0), lineWidth: CGFloat(1.0),
58 stages: [25.0, 50.0, 75.0])