// The pencilled oval round a face's selected part (the invitation, 28 Oct // 2026, `lake-place-selected.png`): drawn by hand in the theme's mark // (`palette.faces.mark`), two passes of a soft pencil that do not quite // close, the first heavier and uneven, the second lighter and a little off. // A face rings a part with `.pencilRinged(_:)`; nothing is drawn when the // part is not the selected one. import CottonPaper import CottonValues import SwiftUI enum PencilRingKnobs { /// The two passes' widths: a pencil pressed, then lifted. static let heavy: CGFloat = 1.5 static let light: CGFloat = 0.9 /// The second pass's strength. static let lightOpacity: Double = 0.75 } /// Two passes of a pencil round an oval, with the pressure varying along /// the first so its stroke is uneven. struct PencilRing: View { @Environment(\.theme) private var theme public init() {} public var body: some View { let mark = theme.faceStocks.mark ZStack { PenRing(start: 0.58, sweep: 1.05, tilt: -1.6) .stroke(mark, style: StrokeStyle(lineWidth: PencilRingKnobs.heavy, lineCap: .round)) // Pressure: a thicker run over part of the first pass. PenRing(start: 0.78, sweep: 0.42, tilt: -1.6) .stroke(mark.opacity(0.6), style: StrokeStyle(lineWidth: PencilRingKnobs.heavy * 1.6, lineCap: .round)) PenRing(start: 0.08, sweep: 0.86, tilt: -0.4, squash: 0.95) .stroke(mark.opacity(PencilRingKnobs.lightOpacity), style: StrokeStyle(lineWidth: PencilRingKnobs.light, lineCap: .round)) .offset(x: 1.2, y: 0.8) } .blendMode(theme.printBlend) .allowsHitTesting(false) .accessibilityHidden(true) } } extension View { /// This view is the card's `part`: ringed in pencil, reaching `reach` /// beyond it, when it is the selected part (`selectedFacePart`). public func pencilRinged(_ part: FacePart, reach: EdgeInsets) -> some View { modifier(PencilRinged(part: part, reach: reach)) } } private struct PencilRinged: ViewModifier { let part: FacePart let reach: EdgeInsets @Environment(\.selectedFacePart) private var selected func body(content: Content) -> some View { content .overlay { if selected == part { PencilRing() .padding(EdgeInsets(top: -reach.top, leading: -reach.leading, bottom: -reach.bottom, trailing: -reach.trailing)) } } .accessibilityAddTraits(selected == part ? .isSelected : []) } }