aboutsummaryrefslogtreecommitdiff
path: root/Sources/Patterns/Tile.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/Tile.swift
parent08da0038960b2b37c88e793c9b8dbe33e7884af5 (diff)
Add the files
Diffstat (limited to 'Sources/Patterns/Tile.swift')
-rw-r--r--Sources/Patterns/Tile.swift35
1 files changed, 35 insertions, 0 deletions
diff --git a/Sources/Patterns/Tile.swift b/Sources/Patterns/Tile.swift
new file mode 100644
index 0000000..c27fcf9
--- /dev/null
+++ b/Sources/Patterns/Tile.swift
@@ -0,0 +1,35 @@
+import SwiftUI
+
+struct Tile: View {
+
+ let pixelSize: CGFloat = 2.0;
+
+ let design: TileDesign
+
+ private var pixels: [Int] {
+ design.pixels()
+ }
+
+ var body: some View {
+ VStack(spacing: 0) {
+ ForEach(0 ..< 8) { i in
+ HStack(spacing: 0) {
+ ForEach(0 ..< 8) { j in
+ Rectangle()
+ .frame(width: pixelSize, height: pixelSize)
+ .foregroundColor(pixels[(i % 8) * 8 + j % 8] == 0
+ ? .black
+ : .white
+ )
+ }
+ }
+ }
+ }
+ }
+}
+
+struct Tile_Previews: PreviewProvider {
+ static var previews: some View {
+ Tile(design: .grid)
+ }
+}