3 public struct Tile: View {
6 var pixelSize: CGFloat = 2.0;
7 var foregroundColor: Color = .black
8 var backgroundColor: Color = .white
10 private var pixels: [Int] {
14 public var body: some View {
16 ForEach(0 ..< 8) { i in
18 ForEach(0 ..< 8) { j in
20 .frame(width: pixelSize, height: pixelSize)
21 .foregroundColor(pixels[(i % 8) * 8 + j % 8] == 0
32 struct Tile_Previews: PreviewProvider {
33 static var previews: some View {
37 Text("Color override")
38 Tile(design: .balls, foregroundColor: .pink, backgroundColor: .cyan)
39 Text("Pixel size override")
40 Tile(design: .shingles, pixelSize: 8.0)