4 struct MapStages: View {
12 ZStack(alignment: .topLeading) {
13 PatternView(design: .constant(.stitch), pixelSize: 1.0, foregroundColor: .map.stageForeground, backgroundColor: .map.stageBackground)
14 .frame(width: w(stages[0]), height: mapSize.height)
15 PatternView(design: .constant(.shingles), pixelSize: 1.0, foregroundColor: .map.stageForeground, backgroundColor: .map.stageBackground)
16 .offset(CGSize(width: w(stages[0]), height: 0))
17 .frame(width: w(stages[1]) - w(stages[0]), height: mapSize.height)
18 PatternView(design: .constant(.shadowGrid), pixelSize: 1.0, foregroundColor: .map.stageForeground, backgroundColor: .map.stageBackground)
19 .offset(CGSize(width: w(stages[1]), height: 0))
20 .frame(width: w(stages[2]) - w(stages[1]), height: mapSize.height)
21 PatternView(design: .constant(.wicker), pixelSize: 1.0, foregroundColor: .map.stageForeground, backgroundColor: .map.stageBackground)
22 .offset(CGSize(width: w(stages[2]), height: 0))
23 .frame(width: mapSize.width - w(stages[2]), height: mapSize.height)
26 path.move(to: CGPoint(x: w(stages[0]), y: 0))
27 path.addLine(to: CGPoint(x: w(stages[0]), y: mapSize.height))
29 path.move(to: CGPoint(x: w(stages[1]), y: 0))
30 path.addLine(to: CGPoint(x: w(stages[1]), y: mapSize.height))
32 path.move(to: CGPoint(x: w(stages[2]), y: 0))
33 path.addLine(to: CGPoint(x: w(stages[2]), y: mapSize.height))
35 path.move(to: CGPoint(x: w(stages[0]), y: 0))
37 }.strokedPath(StrokeStyle(lineWidth: lineWidth / 4, dash: [10.0, 18.0])).stroke(Color.map.axisColor)
41 func w(_ dimension: CGFloat) -> CGFloat {
42 max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
46 struct MapStages_Previews: PreviewProvider {
47 static var previews: some View {
49 mapSize: CGSize(width: 200.0, height: 200.0), lineWidth: CGFloat(0.5),
50 stages: [25.0, 50.0, 75.0])