damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

FillAndStroke.swift (707B)


      1 //
      2 //  FillAndStroke.swift
      3 //  damus
      4 //
      5 //  Created by William Casarin on 2023-05-09.
      6 //
      7 
      8 import Foundation
      9 import SwiftUI
     10 
     11 extension Shape {
     12     func fill<Fill: ShapeStyle, Stroke: ShapeStyle>(_ fillStyle: Fill, strokeBorder strokeStyle: Stroke, lineWidth: Double = 1) -> some View {
     13         self
     14             .stroke(strokeStyle, lineWidth: lineWidth)
     15             .background(self.fill(fillStyle))
     16     }
     17 }
     18 
     19 extension InsettableShape {
     20     func fill<Fill: ShapeStyle, Stroke: ShapeStyle>(_ fillStyle: Fill, strokeBorder strokeStyle: Stroke, lineWidth: Double = 1) -> some View {
     21         self
     22             .strokeBorder(strokeStyle, lineWidth: lineWidth)
     23             .background(self.fill(fillStyle))
     24     }
     25 }