aboutsummaryrefslogtreecommitdiff
path: root/Map/MapRenderComponents
diff options
context:
space:
mode:
Diffstat (limited to 'Map/MapRenderComponents')
-rw-r--r--Map/MapRenderComponents/MapAxes.swift10
-rw-r--r--Map/MapRenderComponents/MapColor.swift45
-rw-r--r--Map/MapRenderComponents/MapVertices.swift53
3 files changed, 52 insertions, 56 deletions
diff --git a/Map/MapRenderComponents/MapAxes.swift b/Map/MapRenderComponents/MapAxes.swift
index e7d65f4..a6e2f87 100644
--- a/Map/MapRenderComponents/MapAxes.swift
+++ b/Map/MapRenderComponents/MapAxes.swift
@@ -8,7 +8,7 @@ struct MapAxes: View {
let lineWidth: CGFloat
let evolution: Stage
let stages: [CGFloat]
- let stageHeight = CGFloat(50.0)
+ let stageHeight = CGFloat(100.0)
let padding = CGFloat(5.0)
var color: Color {
@@ -40,13 +40,13 @@ struct MapAxes: View {
Text("Uncharted")
.font(.title3)
.foregroundColor(color)
- .frame(width: mapSize.width / 4, height: stageHeight, alignment: .topLeading)
- .offset(CGSize(width: 0.0, height: -stageHeight / 2.0))
+ .frame(width: mapSize.width / 4, height: stageHeight / 2.0, alignment: .topLeading)
+ .offset(CGSize(width: 0.0, height: -stageHeight / 4.0))
Text("Industrialised")
.font(.title3)
.foregroundColor(color)
- .frame(width: mapSize.width / 4, height: stageHeight, alignment: .topLeading)
- .offset(CGSize(width: mapSize.width - 100.0, height: -stageHeight / 2.0))
+ .frame(width: mapSize.width / 4, height: stageHeight / 2.0, alignment: .topLeading)
+ .offset(CGSize(width: mapSize.width - 100.0, height: -stageHeight / 4.0))
Text(evolution.i)
.font(.title3)
diff --git a/Map/MapRenderComponents/MapColor.swift b/Map/MapRenderComponents/MapColor.swift
deleted file mode 100644
index ce3d453..0000000
--- a/Map/MapRenderComponents/MapColor.swift
+++ /dev/null
@@ -1,45 +0,0 @@
-import SwiftUI
-
-struct MapColor {
- let foreground: Color
- let background: Color
- let secondary: Color
- let blocker: Color
- let opportunity: Color
- let stages: StageColor
-
- static func colorForScheme(_ colorScheme: ColorScheme) -> MapColor {
- if colorScheme == .dark {
- return MapColor(
- foreground: Color.white,
- background: Color(.sRGB, red: 0.13, green: 0.13, blue: 0.13),
- secondary: Color(.sRGB, red: 0.81, green: 0.78, blue: 0.79),
- blocker: Color(.sRGB, red: 0.13, green: 0.13, blue: 0.13),
- opportunity: Color(.sRGB, red: 1.0, green: 0.37, blue: 0.34),
- stages: StageColor(
- i: Color(.sRGB, red: 0.37, green: 0.16, blue: 0.25),
- ii: Color(.sRGB, red: 0.30, green: 0.29, blue: 0.26),
- iii: Color(.sRGB, red: 0.15, green: 0.29, blue: 0.23),
- iv: Color(.sRGB, red: 0.14, green: 0.22, blue: 0.31)))
- } else {
- return MapColor(
- foreground: Color(.sRGB, red: 0.13, green: 0.13, blue: 0.13),
- background: Color.white,
- secondary: Color.gray,
- blocker: Color(.sRGB, red: 0.60, green: 0.52, blue: 0.51),
- opportunity: Color(.sRGB, red: 1.0, green: 0.37, blue: 0.34),
- stages: StageColor(
- i: Color(.sRGB, red: 1.00, green: 0.93, blue: 0.97),
- ii: Color(.sRGB, red: 1.00, green: 0.98, blue: 0.92),
- iii: Color(.sRGB, red: 0.93, green: 1.00, blue: 0.97),
- iv: Color(.sRGB, red: 0.93, green: 0.96, blue: 1.00)))
- }
- }
-}
-
-struct StageColor {
- let i: Color
- let ii: Color
- let iii: Color
- let iv: Color
-}
diff --git a/Map/MapRenderComponents/MapVertices.swift b/Map/MapRenderComponents/MapVertices.swift
index 71f85be..24d49b8 100644
--- a/Map/MapRenderComponents/MapVertices.swift
+++ b/Map/MapRenderComponents/MapVertices.swift
@@ -15,12 +15,7 @@ struct MapVertices: View {
var body: some View {
ForEach(vertices, id: \.id) { vertex in
- Path { path in
- path.addEllipse(
- in: CGRect(
- origin: CGPoint(x: w(vertex.position.x), y: h(vertex.position.y)), size: vertexSize
- ))
- }.fill(color.foreground)
+ getVertexShape(vertex).fill(color.foreground)
Text(vertex.label).foregroundColor(color.secondary).offset(
CGSize(
width: w(vertex.position.x) + vertexSize.width + padding,
@@ -35,6 +30,52 @@ struct MapVertices: View {
func w(_ dimension: CGFloat) -> CGFloat {
max(0.0, min(mapSize.width, dimension * mapSize.width / 100.0))
}
+
+ func getVertexShape(_ vertex: Vertex) -> Path {
+ switch vertex.shape {
+ case .circle:
+ return Path { path in
+ path.addEllipse(
+ in: CGRect(
+ origin: CGPoint(x: w(vertex.position.x), y: h(vertex.position.y)), size: vertexSize
+ ))
+ }
+ case .square:
+ return Path { path in
+ path.addRect(
+ CGRect(
+ x: w(vertex.position.x), y: h(vertex.position.y), width: vertexSize.width,
+ height: vertexSize.height
+ ))
+ }
+ case .triangle:
+ return Path { path in
+ path.move(to: CGPoint(x: w(vertex.position.x), y: h(vertex.position.y) + vertexSize.height))
+ path.addLine(
+ to: CGPoint(
+ x: w(vertex.position.x) + vertexSize.width, y: h(vertex.position.y) + vertexSize.height)
+ )
+ path.addLine(
+ to: CGPoint(x: w(vertex.position.x) + vertexSize.width / 2.0, y: h(vertex.position.y)))
+ path.addLine(
+ to: CGPoint(x: w(vertex.position.x), y: h(vertex.position.y) + vertexSize.height))
+ path.closeSubpath()
+ }
+ case .x:
+ return Path { path in
+ path.move(to: CGPoint(x: w(vertex.position.x), y: h(vertex.position.y)))
+ path.addLine(
+ to: CGPoint(
+ x: w(vertex.position.x) + vertexSize.width, y: h(vertex.position.y) + vertexSize.height)
+ )
+ path.closeSubpath()
+ path.move(to: CGPoint(x: w(vertex.position.x) + vertexSize.width, y: h(vertex.position.y)))
+ path.addLine(
+ to: CGPoint(x: w(vertex.position.x), y: h(vertex.position.y) + vertexSize.height))
+ path.closeSubpath()
+ }.strokedPath(StrokeStyle(lineWidth: 5.0, lineCap: .butt))
+ }
+ }
}
struct MapVertices_Previews: PreviewProvider {