diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-04-28 22:23:36 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-04-28 22:23:36 +0200 |
| commit | ba4ee0edf2aba19ad73fa53cb01dd0fb9b527526 (patch) | |
| tree | 111357314127f7e05724b570ed9c6aad6f66e3a2 /Sources/Patterns/Tile.swift | |
| parent | 428153379e8653d38a1e9da441a06f0956492b2b (diff) | |
Use CoreGraphics to draw instead of SwifTUI2.0.0
Diffstat (limited to 'Sources/Patterns/Tile.swift')
| -rw-r--r-- | Sources/Patterns/Tile.swift | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/Sources/Patterns/Tile.swift b/Sources/Patterns/Tile.swift deleted file mode 100644 index 9c39640..0000000 --- a/Sources/Patterns/Tile.swift +++ /dev/null @@ -1,50 +0,0 @@ -import SwiftUI - -public struct Tile: View { - - public let design: TileDesign - public var pixelSize: CGFloat = 2.0; - public var foregroundColor: Color = .black - public var backgroundColor: Color = .white - - private var pixels: [Int] { - design.pixels() - } - - public init(design: TileDesign, pixelSize: CGFloat = 2.0, foregroundColor: Color = .black, backgroundColor: Color = .white) { - self.design = design - self.pixelSize = pixelSize - self.foregroundColor = foregroundColor - self.backgroundColor = backgroundColor - } - - public var body: some View { - VStack(spacing: 0) { - ForEach(0 ..< 8) { i in - HStack(spacing: 0) { - ForEach(0 ..< 8) { j in - Rectangle() - .frame(width: pixelSize, height: pixelSize) - .foregroundColor(pixels[(i % 8) * 8 + j % 8] == 0 - ? foregroundColor - : backgroundColor - ) - } - } - } - } - } -} - -struct Tile_Previews: PreviewProvider { - static var previews: some View { - VStack { - Text("Default") - Tile(design: .grid) - Text("Color override") - Tile(design: .balls, foregroundColor: .pink, backgroundColor: .cyan) - Text("Pixel size override") - Tile(design: .shingles, pixelSize: 8.0) - } - } -} |