SwiftUI tiling black and white patterns.
-This project contains `Patterns`, which are built out of `Tiles` with a given
+This project contains `PatternView`, which is built out of `Tiles` with a given
`TileDesign`.
It also includes a `TilePicker` that can be used to control the selected
## Usage
-The `Pattern` view will tile the selected design in its frame. It has the
+The `PatternView` view will tile the selected design in its frame. It has the
following properties:
* `design: Binding<TileDesign>`: **required**, which design to use to tile the
* `backgroundColor: Color`: **defaults to `Color.white`**, the background color.
```
-// Pattern using default settings
-Pattern(design: .constant(TileDesign.shadowGrid))
+// PatternView using default settings
+PatternView(design: .constant(TileDesign.shadowGrid))
-// Pattern using overrides
-Pattern(design: $tileDesign, pixelSize: 4.0, foregroundColor: .pink, backgroundColor: .cyan)
+// PatternView using overrides
+PatternView(design: $tileDesign, pixelSize: 4.0, foregroundColor: .pink, backgroundColor: .cyan)
```
### Screenshots of the Patterns
...
-Pattern(design: $pattern)
+PatternView(design: $design)
.frame(width: 32.0).border(.black)
.onTapGesture {
shouldShowPatternPicker = !shouldShowPatternPicker;
.popover(isPresented: $shouldShowPatternPicker) {
PatternPicker(selectedDesign: $design)
}
- .onChange(of: pattern) { _ in
+ .onChange(of: design) { _ in
shouldShowPatternPicker = false;
}
```
* watchOS 8+
* catalyst 15+
-## The Tile view
+## The TileImage struct
If you'd like to do other things with the individual tiles, we also provide the
-Tile view, which is just a single tile.
+TileImage struct, which generates a CGImage.
-The tiles support the same properties as `Pattern` with the exception that
-`design` is a `TileDesign` and not a `Binding<TileDesign>`
+The tiles support similar properties as `PatternView` with the exception that
+
+* `design: TileDesign`: **required**, which design to use to tile the frame.
+* `pixelSize: CGFloat`: **defaults to 2.0**, the size of a pixel in the tile.
+* `foregroundColor: CGColor`: **defaults to black**, the foreground color.
+* `backgroundColor: CGColor`: **defaults to white**, the background color.
![Screenshots of the tiles showing the different overrides](./doc/images/tile_example.png)