3 public struct Pattern: View {
5 @Binding public var design: TileDesign;
6 public var pixelSize: CGFloat = 2.0;
7 public var foregroundColor: Color = .black
8 public var backgroundColor: Color = .white
10 private var patternSize: CGFloat {
14 public var body: some View {
15 GeometryReader { gr in
17 ForEach(0 ..< 1 + Int(ceil(gr.size.height / patternSize)), id: \.self) { i in
19 ForEach(0 ..< Int(ceil(gr.size.width / patternSize)), id: \.self) { j in
20 Tile(design: design, pixelSize: pixelSize, foregroundColor: foregroundColor, backgroundColor: backgroundColor)
29 struct Pattern_Previews: PreviewProvider {
30 static var previews: some View {
33 Pattern(design: .constant(TileDesign.grid))
34 Text("Color override")
35 Pattern(design: .constant(TileDesign.balls), foregroundColor: .pink, backgroundColor: .cyan)
36 Text("Pixel size override")
37 Pattern(design: .constant(TileDesign.shingles), pixelSize: 8.0)