3 struct MapBlockers: View {
5 @Environment(\.colorScheme) var colorScheme
9 let blockers: [Blocker]
12 MapColor.colorForScheme(colorScheme).blocker
15 let cornerSize = CGSize(width: 2.0, height: 2.0)
18 ForEach(blockers, id: \.id) { vertex in
23 x: w(vertex.position.x) + 3 * vertexSize.width,
24 y: h(vertex.position.y) - vertexSize.height * 2 / 3),
25 size: CGSize(width: vertexSize.width / 2, height: vertexSize.height * 2)
26 ), cornerSize: cornerSize)
31 func h(_ dimension: CGFloat) -> CGFloat {
32 max(0.0, min(mapSize.height, dimension * mapSize.height / 100.0))
35 func w(_ dimension: CGFloat) -> CGFloat {
36 max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
40 struct MapBlockers_Previews: PreviewProvider {
41 static var previews: some View {
43 mapSize: CGSize(width: 400.0, height: 400.0), vertexSize: CGSize(width: 25.0, height: 25.0),
45 Blocker(id: 0, position: CGPoint(x: 50.0, y: 50.0)),
46 Blocker(id: 1, position: CGPoint(x: 10.0, y: 20.0)),