]> git.r.bdr.sh - rbdr/patterns/blame - Sources/Patterns/Tile.swift
Add the files
[rbdr/patterns] / Sources / Patterns / Tile.swift
CommitLineData
8b0b5b39
RBR
1import SwiftUI
2
3struct Tile: View {
4
5 let pixelSize: CGFloat = 2.0;
6
7 let design: TileDesign
8
9 private var pixels: [Int] {
10 design.pixels()
11 }
12
13 var body: some View {
14 VStack(spacing: 0) {
15 ForEach(0 ..< 8) { i in
16 HStack(spacing: 0) {
17 ForEach(0 ..< 8) { j in
18 Rectangle()
19 .frame(width: pixelSize, height: pixelSize)
20 .foregroundColor(pixels[(i % 8) * 8 + j % 8] == 0
21 ? .black
22 : .white
23 )
24 }
25 }
26 }
27 }
28 }
29}
30
31struct Tile_Previews: PreviewProvider {
32 static var previews: some View {
33 Tile(design: .grid)
34 }
35}