2 Copyright (C) 2024 Rubén Beltrán del Río
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see https://map.tranquil.systems.
20 struct MapStages: View {
23 let lineWidth: CGFloat
28 ZStack(alignment: .topLeading) {
30 design: .constant(.stitch), pixelSize: 1.0, foregroundColor: .map.stageForeground,
31 backgroundColor: .map.stageBackground
33 .frame(width: w(stages[0]), height: mapSize.height)
35 design: .constant(.shingles), pixelSize: 1.0, foregroundColor: .map.stageForeground,
36 backgroundColor: .map.stageBackground
38 .offset(CGSize(width: w(stages[0]), height: 0))
39 .frame(width: w(stages[1]) - w(stages[0]), height: mapSize.height)
41 design: .constant(.shadowGrid), pixelSize: 1.0, foregroundColor: .map.stageForeground,
42 backgroundColor: .map.stageBackground
44 .offset(CGSize(width: w(stages[1]), height: 0))
45 .frame(width: w(stages[2]) - w(stages[1]), height: mapSize.height)
47 design: .constant(.wicker), pixelSize: 1.0, foregroundColor: .map.stageForeground,
48 backgroundColor: .map.stageBackground
50 .offset(CGSize(width: w(stages[2]), height: 0))
51 .frame(width: mapSize.width - w(stages[2]), height: mapSize.height)
54 path.move(to: CGPoint(x: w(stages[0]), y: 0))
55 path.addLine(to: CGPoint(x: w(stages[0]), y: mapSize.height))
57 path.move(to: CGPoint(x: w(stages[1]), y: 0))
58 path.addLine(to: CGPoint(x: w(stages[1]), y: mapSize.height))
60 path.move(to: CGPoint(x: w(stages[2]), y: 0))
61 path.addLine(to: CGPoint(x: w(stages[2]), y: mapSize.height))
63 path.move(to: CGPoint(x: w(stages[0]), y: 0))
65 }.strokedPath(StrokeStyle(lineWidth: lineWidth / 4, dash: [10.0, 18.0])).stroke(
70 func w(_ dimension: CGFloat) -> CGFloat {
71 max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
77 mapSize: CGSize(width: 200.0, height: 200.0), lineWidth: CGFloat(0.5),
78 stages: [25.0, 50.0, 75.0])