aboutsummaryrefslogtreecommitdiff
path: root/Sources/Patterns/Pattern.swift
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2023-04-26 16:25:43 +0200
committerRuben Beltran del Rio <ruben@unlimited.pizza>2023-04-26 16:25:43 +0200
commit8b0b5b394e5eca8538956fecbaa70ca66fdde24b (patch)
treed627bb4c4870f43dbc926df5d65dcc84cd2c53de /Sources/Patterns/Pattern.swift
parent08da0038960b2b37c88e793c9b8dbe33e7884af5 (diff)
Add the files
Diffstat (limited to 'Sources/Patterns/Pattern.swift')
-rw-r--r--Sources/Patterns/Pattern.swift32
1 files changed, 32 insertions, 0 deletions
diff --git a/Sources/Patterns/Pattern.swift b/Sources/Patterns/Pattern.swift
new file mode 100644
index 0000000..1951888
--- /dev/null
+++ b/Sources/Patterns/Pattern.swift
@@ -0,0 +1,32 @@
+import SwiftUI
+
+public struct Pattern: View {
+
+ private let pixelSize: CGFloat = 2.0;
+
+ private var patternSize: CGFloat {
+ pixelSize * 8.0;
+ }
+
+ @Binding var design: TileDesign;
+
+ public var body: some View {
+ GeometryReader { gr in
+ VStack(spacing: 0) {
+ ForEach(0 ..< 1 + Int(ceil(gr.size.height / patternSize)), id: \.self) { i in
+ HStack(spacing: 0) {
+ ForEach(0 ..< Int(ceil(gr.size.width / patternSize)), id: \.self) { j in
+ Tile(design: design)
+ }
+ }
+ }
+ }
+ }.drawingGroup()
+ }
+}
+
+struct Pattern_Previews: PreviewProvider {
+ static var previews: some View {
+ Pattern(design: .constant(TileDesign.grid))
+ }
+}