summaryrefslogtreecommitdiff
path: root/makima/ios/Sources/Makima/Design/Components/GridOverlay.swift
diff options
context:
space:
mode:
Diffstat (limited to 'makima/ios/Sources/Makima/Design/Components/GridOverlay.swift')
-rw-r--r--makima/ios/Sources/Makima/Design/Components/GridOverlay.swift29
1 files changed, 29 insertions, 0 deletions
diff --git a/makima/ios/Sources/Makima/Design/Components/GridOverlay.swift b/makima/ios/Sources/Makima/Design/Components/GridOverlay.swift
new file mode 100644
index 0000000..824d0b2
--- /dev/null
+++ b/makima/ios/Sources/Makima/Design/Components/GridOverlay.swift
@@ -0,0 +1,29 @@
+import SwiftUI
+
+/// Subtle grid, mirrors the makima.jp body background texture.
+/// Drawn as a `Canvas` so there's no asset dependency.
+struct GridOverlay: View {
+ var spacing: CGFloat = 32
+ var opacity: Double = 0.04
+
+ var body: some View {
+ Canvas { ctx, size in
+ let color = GraphicsContext.Shading.color(.white.opacity(opacity))
+ var path = Path()
+ var x = spacing
+ while x < size.width {
+ path.move(to: CGPoint(x: x, y: 0))
+ path.addLine(to: CGPoint(x: x, y: size.height))
+ x += spacing
+ }
+ var y = spacing
+ while y < size.height {
+ path.move(to: CGPoint(x: 0, y: y))
+ path.addLine(to: CGPoint(x: size.width, y: y))
+ y += spacing
+ }
+ ctx.stroke(path, with: color, lineWidth: 0.5)
+ }
+ .allowsHitTesting(false)
+ }
+}