]>
Commit | Line | Data |
---|---|---|
1 | import SwiftUI | |
2 | ||
3 | public struct Pattern: View { | |
4 | ||
5 | private let pixelSize: CGFloat = 2.0; | |
6 | ||
7 | private var patternSize: CGFloat { | |
8 | pixelSize * 8.0; | |
9 | } | |
10 | ||
11 | @Binding var design: TileDesign; | |
12 | ||
13 | public var body: some View { | |
14 | GeometryReader { gr in | |
15 | VStack(spacing: 0) { | |
16 | ForEach(0 ..< 1 + Int(ceil(gr.size.height / patternSize)), id: \.self) { i in | |
17 | HStack(spacing: 0) { | |
18 | ForEach(0 ..< Int(ceil(gr.size.width / patternSize)), id: \.self) { j in | |
19 | Tile(design: design) | |
20 | } | |
21 | } | |
22 | } | |
23 | } | |
24 | }.drawingGroup() | |
25 | } | |
26 | } | |
27 | ||
28 | struct Pattern_Previews: PreviewProvider { | |
29 | static var previews: some View { | |
30 | Pattern(design: .constant(TileDesign.grid)) | |
31 | } | |
32 | } |