// The inks of the faces' own pieces on a card's paper: every colour is the // theme's (`palette.faces`), every strength the card paper's scale. The // face-only pieces — a tag of paper, a photograph's mount, the initials' // mount — keep their inks here; the stock each face is printed on is the // face's own (`onCardPaper`, CottonPaper's `CardPaper`). import CottonPaper import SwiftUI /// The inks of the faces' own pieces, as the worn theme says them /// (`palette.faces`); an ink's strength is its colour's alpha. public struct FaceStockTokens { public var cream: Color public var buff: Color public var shadow: Color public var shadowOpacity: Double public var ornament: Color public var ruling: Color public var margin: Color public var mountInk: Color /// The slip of paper the corner's words sit on (image 2a). public var cornerSlip: Color /// The aged-cream mount round a photograph (image 9). public var printMount: Color /// The pencilled mark round a face's selected part. public var mark: Color public var passportInk: Color public var passportStamps: [Color] } extension Theme { public var faceStocks: FaceStockTokens { let faces = colors.faces func ink(_ key: String) -> Color { faces[key]?.color ?? .clear } return FaceStockTokens( cream: ink("cream"), buff: ink("buff"), shadow: ink("shadow"), shadowOpacity: Double(scale[.cardShadowOpacity]), ornament: ink("ornament"), ruling: ink("ruling"), margin: ink("margin"), mountInk: ink("initials"), cornerSlip: ink("slip"), printMount: ink("mount"), mark: ink("mark"), passportInk: ink("passport_ink"), passportStamps: [ink("passport_red"), ink("passport_violet"), ink("passport_blue"), ink("passport_brown")] ) } } /// Typed ink on the stock: the colour, multiplied into the fibre. struct FaceInk: ViewModifier { let ink: PaperInk @Environment(\.theme) private var theme func body(content: Content) -> some View { content .foregroundStyle(theme.print(ink)) .blendMode(theme.printBlend) } } extension View { public func faceInk(_ ink: PaperInk) -> some View { modifier(FaceInk(ink: ink)) } } /// A photograph mounted on the card: square-cut, flat to the stock, a hair /// of shadow where it lifts (image 2a's portrait). public struct MountedPrint: View { /// The picture, filling whatever frame it is given. let photo: Photo @Environment(\.theme) private var theme public init(photo: Photo) { self.photo = photo } public var body: some View { Color.clear .overlay(photo) .clipped() .shadow(color: theme.colors.shadow.color.opacity(theme.faceStocks.shadowOpacity), radius: 1.2, x: 0, y: 0.8) .accessibilityHidden(true) } }