Cotton code
639 lines · 31.0 KB · SwiftRaw
// A tool, as a CARD — Home's directory, printed as a deck.//// The owner's design of 2026-09-16, from a reference sheet he chose ("I do like// the cards quite a bit… I do like the colors… symmetry"): every tool is a// portrait card of tinted stock with a printed frame, the tool's own// photographed object standing in the upper two thirds, a short rule, and the// tool's name set in a serif under it.//// **THE CARD IS A PHOTOGRAPH, NOT A DRAWING.** The first build drew it — a// rounded rectangle, a palette tint, a grain tile and a stroked border — and it// came back the same day: *"the cards are not as aesthetic as the image I// uploaded — the image had a frame and all that."* He was right, and the reason// is the one the project caps already settled: a photographed object standing// on a drawn rectangle reads as a sticker on a swatch, because the object// carries a lens, a light and fifty years of wear and the rectangle carries// none. So the card follows the caps exactly — **photograph the blank, print on// it live.** `stock-cream` … `stock-grey` in `Media.xcassets` are six blank// aged card faces, each cut on its own ALPHA so its worn, bumped edge survives// (a `RoundedRectangle` clip would cut it off straight), and everything that// changes — the object, the rule, the name — is drawn on top.// `scripts/gen-cards/{make_card_faces,export_card_faces}.py` are how they were// made and how they are remade; `preview_card.py` is how the four live pieces// were placed on them, because a fraction two points out is invisible in// source and obvious on a screen.//// **THE STOCK IS BAKED INTO THE PHOTOGRAPH**, the way a project cap's enamel is// baked into `cap-red.png`. There are no card colour tokens in the palette:// `ToolCardTint` names an ASSET and the colour is in the pixels. (The first// build put six tints in `design/palette.rs`; nothing read them once the faces// were photographs, and a token nothing reads is noise.) The six were still// DECIDED rather than accepted — the exporter corrects each panel to a colour// sampled off the owner's own sheet, because an image model answers a colour// instruction with a salmon and an olive, and a stock that fights the plaster// is the note this card came back with the first time.//// **WHAT IS PRINTED, AND WHERE.** The name is set UNDER the object now, so the// name printed ON the object (`ToolPrint`, #720) would be the same word twice.// The objects are therefore drawn with `printing: .contentOnly`: the picture// keeps every print that is CONTENT and loses every print that is its own// label. There is exactly one print that is content — the calendar's `SEP 16`,// which is a date and not the word "Calendar" — so the calendar's pad still// reprints itself every day and every other object comes up bare.//// `ToolObject` is untouched and still draws the printed name at its default,// because it is still what the Mac's sidebar draws.//// **THE TINT IS THE STOCK, AND IT IS NEVER STATE.** Six papers, one per tool// FAMILY — the writing papers cream, time and intention sage, people rose,// pictures slate, money and places tan, what is read and what is kept shut// grey. Nothing reads a tint to learn anything: not a count, not a state, not// whether something waits. The map is TOTAL over the twenty-four keys Home// draws (`ToolCardTests`), because a key with no stock would silently draw the// plainest card in the deck and read as a tool with nothing in it.//// **THE CARD IS ONE ELEMENT.** The picture is a photograph and the name under it// is a picture of a word until it is read out loud once: the card states its// name (`accessibilityLabel`) and everything inside it is ignored, exactly as// the object did on its own.import CottonValuesimport SwiftUI// MARK: - The stock/// The six papers Home's deck is cut from. A stock, not a role: see the header.public typealias ToolCardTint = DefinitionCardStockextension DefinitionCardStock {    /// The photographed blank in `Media.xcassets`. The colour is IN it — there    /// is no tint to apply over the top, and applying one would flatten the    /// foxing and the vignette that make it paper.    public var asset: String { "stock-\(rawValue)" }    /// **Which stock each tool is printed on, by family**, by the kit    /// tools' keys — the fallback a package tool that names no stock of its    /// own is printed on. Every key is in exactly one family because a    /// dictionary cannot put one in two. The app ships no tool (owner's    /// ruling, 21 Oct 2026), so a key here is a stock, never a tool.    ///    /// The families are the ones the deck reads as, not the ones a database    /// would draw: what you write (cream), what holds your time (sage), the    /// people and what passes between you (rose), the pictures and recordings    /// (slate), money, places and things (tan), and what you read or keep shut    /// (grey).    public static let byTool: [String: ToolCardTint] = [        // What you write.        "notes": .cream,        "journal": .cream,        "thoughts": .cream,        "documents": .cream,        // A coding session is writing too — and its object is a paper printout.        "code": .cream,        // What holds your time and your intentions.        "todos": .sage,        "calendar": .sage,        "goals": .sage,        "meetings": .sage,        "alarms": .sage,        // The people, and what passes between you — your own feeling included.        "messages": .rose,        "email": .rose,        "calls": .rose,        "people": .rose,        "mood": .rose,        // Who else holds this database: people, like the address book.        "members": .rose,        // The pictures and the recordings.        "photos": .slate,        "stories": .slate,        "videos": .slate,        // Money, places, things.        "accounts": .tan,        "locations": .tan,        // The machines that hold this database are things you own, like a        // shop or a place — and they are nothing you write, nothing that        // holds your time and nobody you talk to.        "devices": .tan,        // The names you hold on the web: property, like the devices.        "domains": .tan,        // Every tool of this database, boxed: a thing you keep shut, like the keys.        "tools": .grey,        // Who may read you: access, kept like the keys and the settings.        "assistants": .grey,        // What was thrown away: kept shut, like the settings.        "bin": .grey,        // What the person told Cotton: a note sent, like the email.        "feedback": .rose,        // What this phone holds, filed away in a drawer: kept shut too.        "storage": .grey,        // Every table, a stack of ledgers: the archive's grey.        "everything": .grey,        // What you read, and what you keep shut.        "news": .grey,        "reader": .grey,        "passwords": .grey,    ]    /// The stock a tool is printed on.    ///    /// A key this build does not know is not a thing that exists — `HomeData`    /// is where Home's keys come from and the map above is held total over it —    /// so the answer for one is the plainest stock in the deck rather than a    /// hole in the grid.    public static func of(_ key: String) -> ToolCardTint { byTool[key] ?? .cream }}// MARK: - The card's arithmetic/// Where the four live pieces sit on the photographed face, as fractions of the/// card's WIDTH or its HEIGHT — so one card is one drawing at 84 points on a/// phone, at 115 in three columns and at whatever a small tile leaves.////// Pure numbers in their own type, because they are what a test can hold: the/// object has to stay inside the face's printed frame, the rule under the/// object and the name under the rule, at every size, and none of that is/// visible in a `body`. `scripts/gen-cards/preview_card.py` mirrors these/// numbers and draws them in a second; it is where a change to one is tried.public struct ToolCardMetrics {    /// The theme's scale every number below is read from.    public let scale: ThemeScale    public init(scale: ThemeScale) { self.scale = scale }    /// Width ÷ height, and the photographed faces' own proportion. 3:4 is what    /// the owner's reference sheet measures (249 × 329 points of it) and the    /// deeper of the two shapes that were on the table: it leaves the name a    /// line of its own under the object instead of crowding it against the    /// rule, which is the half of the card a 4:5 crop takes first.    public var aspect: CGFloat { ToolCardKnobs.toolCardAspect }    /// How far inside the card's edge the face's own printed frame runs —    /// MEASURED off `stock-cream.png`, not chosen: it is the line the live    /// pieces have to stay inside, so it belongs to the photograph.    public var contentInset: CGFloat { ToolCardKnobs.toolCardContentInset }    /// The object's side, as a fraction of the card's width.    ///    /// Bigger than it looks: the cut-outs were photographed with ~6 % padding of    /// their own and most are taller than they are wide, so a SQUARE of 0.78    /// puts about 0.6 of the card's width of actual object on the paper — the    /// reference sheet's proportion.    public var objectFraction: CGFloat { ToolCardKnobs.toolCardObjectFraction }    /// Where the object's centre sits, down the card's height.    public var objectCentre: CGFloat { ToolCardKnobs.toolCardObjectCentre }    /// The object's shadow on the card: how far it is dropped, how far it is    /// spread, and how dark it lands. A card lying flat under one soft light    /// has one of these, and the reference's cards all do — without it the    /// cut-out floats a millimetre above its own paper.    public var shadowDrop: CGFloat { ToolCardKnobs.toolCardShadowDropFraction }    public var shadowBlur: CGFloat { ToolCardKnobs.toolCardShadowBlurFraction }    public var shadowOpacity: CGFloat { ToolCardKnobs.toolCardShadowOpacity }    /// The rule under the object: where it sits, and how wide it runs.    public var ruleCentre: CGFloat { CardStockKnobs.toolCardRuleCentre }    public var ruleWidth: CGFloat { CardStockKnobs.toolCardRuleWidth }    /// The name: where its line sits, and its point size against the width.    public var nameCentre: CGFloat { ToolCardKnobs.toolCardNameCentre }    public var nameFraction: CGFloat { ToolCardKnobs.toolCardNameFraction }    /// The height a card of this width is drawn at.    public func height(width: CGFloat) -> CGFloat { width / aspect }    /// The rule's own thickness — never under half a point, or it drops off a    /// 2x screen entirely.    public func hairline(width: CGFloat) -> CGFloat {        max(CardStockKnobs.toolCardRuleHairlineMin, width * CardStockKnobs.toolCardRuleHairlineFraction)    }    /// The object's side on a card `width` across.    public func objectSide(width: CGFloat) -> CGFloat { width * objectFraction }    /// The name's point size on a card `width` across.    public func nameSize(width: CGFloat) -> CGFloat { width * nameFraction }    /// The stock cropped to a slot shorter than the card (a board's small    /// tile): the photograph is laid at its own height    /// twice — once from the slot's bottom, once from its top — and each copy    /// keeps one half of the slot, so the plain middle goes and the printed    /// frame and corners stay. In drawing order: the lower half first, the    /// upper half over the one point they share.    ///    /// `laid` runs past the slot; `kept` is all that is drawn, touched and    /// read out, and lies inside the slot (walker294 row 111: the laid copies    /// were the tile's frame, 0.147 of the screen on a 0.102 row step).    public func stockHalves(size: CGSize) -> [(laid: CGRect, kept: CGRect)] {        let tall = height(width: size.width)        let half = size.height * 0.5        let lower = CGRect(x: 0, y: size.height - tall, width: size.width, height: tall)        let upper = CGRect(x: 0, y: 0, width: size.width, height: tall)        return [            (laid: lower, kept: CGRect(x: 0, y: max(0, half - 1), width: size.width, height: size.height - max(0, half - 1))),            (laid: upper, kept: CGRect(x: 0, y: 0, width: size.width, height: half)),        ]    }}// MARK: - One card/// One tool's card: the photographed stock, the object and its shadow, the rule/// and the name. Portrait; the caller decides the width.public struct ToolCard: View {    @Environment(\.theme) private var theme    private let key: String    private let name: String    private let picture: ToolPicture?    private let stock: ToolCardTint?    private let now: Date    private let width: CGFloat?    private let imageVariant: ToolImageVariant    private let fillsSpace: Bool    /// A person's own card (Me): their print in the object's place.    private let face: HomeFace?    /// The fan rests on it: a look that names a fill for the current tile    /// (`Theme.currentTileFill`) fills it, its name in the fill's ink.    private let current: Bool    /// **`width` is the card's own width, when the caller already knows it.**    ///    /// A deck's cards are all one width, and the deck knows it — the columns    /// are flexible with a constant gap, so the figure is one subtraction from    /// the grid's width (Home's deck). Handing it down means a    /// whole deck costs ONE measurement instead of one    /// `GeometryReader`s, each of which is a layout container of its own.    ///    /// `nil` measures, which is what a caller that places one card — a board    /// tile — wants: the card fills what it is given at its own    /// aspect. `fillsSpace` crops only plain stock to fit a tile's slot; the    /// object, frame edges and lettering retain their proportions.    public init(        key: String, name: String, picture: ToolPicture?, stock: ToolCardTint? = nil, now: Date = Date(),        width: CGFloat? = nil, imageVariant: ToolImageVariant = .full, fillsSpace: Bool = false, face: HomeFace? = nil,        current: Bool = false    ) {        self.face = face        self.current = current        self.key = key        self.name = name        self.picture = picture        self.stock = stock        self.now = now        self.width = width        self.imageVariant = imageVariant        self.fillsSpace = fillsSpace    }    /// A card whose picture is one of the objects the app ships.    public init(        key: String, name: String, asset: String?, now: Date = Date(), width: CGFloat? = nil,        imageVariant: ToolImageVariant = .full, fillsSpace: Bool = false    ) {        self.init(            key: key, name: name, picture: asset.map(ToolPicture.asset), now: now, width: width,            imageVariant: imageVariant, fillsSpace: fillsSpace        )    }    /// The tool's own stock when its definition names one; the map is the    /// default a definition was seeded from.    private var tint: ToolCardTint { stock ?? ToolCardTint.of(key) }    /// Where the live pieces sit, read off the theme.    private var metrics: ToolCardMetrics { ToolCardMetrics(scale: theme.scale) }    public var body: some View {        sized            // One element, and it says the tool's name once: the object is a            // photograph and the word under it is a picture of a word.            .accessibilityElement(children: .ignore)            .accessibilityLabel(name)    }    @ViewBuilder private var sized: some View {        if let width {            face(size: CGSize(width: width, height: metrics.height(width: width)))                // **The finished card is a PICTURE, so it is drawn once and                // kept.** Twenty-four of these are on Home at all times, and                // each is a photograph, a hairline and two blended text runs                // — a tree the compositor re-composited on every frame of                // every scroll. Nothing in it moves or takes a tap of its own                // (the press and the hold are the grid's), so it is a STATIC                // DISPLAY BOUNDARY.                //                // **On the sized path alone**, which is the scrolling deck's:                // a card that measures itself is placed once and does not                // scroll, so it needs no texture.                .drawingGroup()        } else if fillsSpace {            // The slot is the card: a cropped stock lays its photograph past            // the slot, and the card is touched and read out as the slot.            GeometryReader { geo in face(size: geo.size) }                .contentShape(.interaction, Rectangle())                .contentShape(.accessibility, Rectangle())        } else {            GeometryReader { geo in                face(size: geo.size)            }            .aspectRatio(metrics.aspect, contentMode: .fit)        }    }    /// The card at a size that is already decided — the four printed pieces,    /// the group that keeps the blends on the stock, and the lift.    @ViewBuilder private func face(size: CGSize) -> some View {        switch theme.family {        case .paper: printed(size: size)        case .plain: flat(size: size)        }    }    /// A flat family's card: the theme's card with its hairline and corner,    /// and the tool's name set on it. No photograph to stand on it. The    /// current tile under a look that names its fill is that fill, edge to    /// edge, its name in the fill's ink (Codex round 2: Sharmila's teal    /// Schedule); a paper card is a photograph and is never filled.    private func flat(size: CGSize) -> some View {        let shape = RoundedRectangle(cornerRadius: theme.scale.radius, style: .continuous)        let fill = current ? theme.currentTileFill : nil        return ZStack {            if let fill {                shape.fill(fill)            } else {                shape.fill(theme.colors.paper.color)                shape.strokeBorder(theme.colors.hairline.color, lineWidth: theme.scale.hairline)            }            let line = ToolCard.flatName(name, theme: theme, width: size.width)            Text(line.words)                .font(theme.type.title(line.size))                .foregroundStyle(fill == nil ? theme.colors.ink.color : theme.fillInk)                .lineLimit(line.lines)                .multilineTextAlignment(.center)                .padding(size.width * metrics.contentInset)                .accessibilityLabel(name)        }        .frame(width: size.width, height: size.height)    }    /// A flat card's name: up to two lines, broken only at a space; a word    /// longer than the card's line even at the caption size ("Membership")    /// stands whole on one line, set smaller to fit — never split inside.    static func flatName(_ name: String, theme: Theme, width: CGFloat) -> (words: String, size: CGFloat, lines: Int) {        let metrics = ToolCardMetrics(scale: theme.scale)        let inner = width * (1 - 2 * metrics.contentInset)        let lines = ToolCardKnobs.toolCardFlatNameLines        let set = InkFit.set(name, face: theme.type.title, preferred: metrics.nameSize(width: width), width: inner,                             lines: lines, scale: theme.scale)        if InkFit.fits(set.words, face: theme.type.title, size: set.size, width: inner, lines: lines) {            return (set.words, set.size, lines)        }        return (set.words, InkFit.oneLine(set.words, face: theme.type.title, size: set.size, width: inner), 1)    }    /// A printed card's caption under its object: one line, whole words,    /// cut at a word with an ellipsis at the floor; a single word longer than    /// the line even at the floor ("Subscriptions" on the fan's tile, 362    /// walk: drawn "Subscription", its last letter past the card's edge)    /// stands whole, set smaller until its ink fits — never cut inside.    static func printedName(_ name: String, theme: Theme, width: CGFloat) -> (words: String, size: CGFloat) {        let metrics = ToolCardMetrics(scale: theme.scale)        let inner = width * (1 - 2 * metrics.contentInset)        let set = InkFit.set(name, face: theme.type.title, preferred: metrics.nameSize(width: width),                             width: inner, lines: 1, floor: ToolCardKnobs.nameFloor, scale: theme.scale)        if InkFit.fits(set.words, face: theme.type.title, size: set.size, width: inner, lines: 1) {            return (set.words, set.size)        }        return (set.words, InkFit.oneLine(set.words, face: theme.type.title, size: set.size, width: inner))    }    private func printed(size: CGSize) -> some View {        ZStack {            stock(size: size)            object(size: size)            rule(size: size)            printedName(size: size)        }        // The blends have to hit the CARD and stop there — without the        // group the ink would multiply straight through to the plaster,        // which is `ToolObject`'s lesson and `ProjectCap`'s before it.        .compositingGroup()        .frame(width: size.width, height: size.height)        // The card lies on the plaster the way a cap does — one soft edge        // shadow, scaled to the card so a small tile and Home's grid        // wear the same lift rather than the same number of points.        .shadow(            color: theme.colors.shadow.color.opacity(theme.texture.shadow == .none ? 0 : Double(ToolCardKnobs.toolCardSurfaceShadowOpacity)),            radius: size.width * ToolCardKnobs.toolCardSurfaceShadowRadiusFraction,            x: 0,            y: size.width * ToolCardKnobs.toolCardSurfaceShadowYFraction        )    }    /// The photographed blank, drawn as it is. No clip: the alpha it was cut on    /// IS the card's edge.    @ViewBuilder private func stock(size: CGSize) -> some View {        if let face = CottonMedia.image(imageVariant.asset(tint.asset)) {            if fillsSpace, size.height < metrics.height(width: size.width) {                // Keep the photographed edges: remove plain stock in the                // middle rather than flattening the frame or the corners.                // Each half is the whole photograph laid past the slot and                // kept to its own half — touched and read out as that half,                // never as the photograph's full height (walker294 row 111).                ZStack(alignment: .topLeading) {                    ForEach(Array(metrics.stockHalves(size: size).enumerated()), id: \.offset) { _, half in                        face.resizable().frame(width: half.laid.width, height: half.laid.height)                            .offset(y: half.laid.minY - half.kept.minY)                            .frame(width: half.kept.width, height: half.kept.height, alignment: .topLeading)                            .clipped()                            .contentShape(.interaction, Rectangle())                            .contentShape(.accessibility, Rectangle())                            .offset(y: half.kept.minY)                    }                }                .frame(width: size.width, height: size.height, alignment: .topLeading)                .accessibilityHidden(true)            } else {                face.resizable().frame(width: size.width, height: size.height).accessibilityHidden(true)            }        }    }    /// The object, in the upper two thirds, over its own shadow — with its NAME    /// left unprinted, because the card prints it below. The calendar keeps its    /// date: that is content, not a label. A person's card stands their print    /// there instead.    @ViewBuilder private func object(size: CGSize) -> some View {        if let face {            HomeFacePrint(face: face, width: metrics.objectSide(width: size.width) * ToolCardKnobs.toolCardFaceFraction)                .position(x: size.width * 0.5, y: size.height * metrics.objectCentre)                .accessibilityHidden(true)        } else {            toolObject(size: size)        }    }    private func toolObject(size: CGSize) -> some View {        let side = fillsSpace            ? min(metrics.objectSide(width: size.width), size.height * ToolCardKnobs.toolCardObjectMaxHeightFraction)            : metrics.objectSide(width: size.width)        // **ONE drawing of the object, with a real shadow under it.** The card        // used to draw the picture TWICE — the lower copy blurred, dimmed,        // dropped and multiplied, as its own shadow — which put two        // photographs, two `GeometryReader`s and a live blur on screen for        // every one of the twenty-four cards, and listed every object twice in        // the accessibility tree. The shadow it was drawing is a shadow: the        // same drop, blur and opacity go to the picture itself        // (`ToolObject.Lift`), which casts it from the PHOTOGRAPH and under        // the prints — so the calendar's date is still ink on the pad rather        // than something hanging above it, which is the reason the second copy        // existed at all.        return ToolObject(            name: name,            picture: picture,            now: now,            printing: .contentOnly,            lift: .drop(                radius: size.width * metrics.shadowBlur,                y: size.width * metrics.shadowDrop,                opacity: metrics.shadowOpacity            ),            // The card knows the square it is putting the object in, so the            // object does not measure one.            side: side,            imageVariant: imageVariant        )        .frame(width: side, height: side)        .position(x: size.width * 0.5, y: size.height * metrics.objectCentre)        .accessibilityHidden(true)    }    private func rule(size: CGSize) -> some View {        Rectangle()            .fill(PrintInk.dark.color.opacity(Double(ToolCardKnobs.toolCardRuleOpacity)))            .frame(                width: size.width * metrics.ruleWidth,                height: metrics.hairline(width: size.width)            )            .blendMode(.multiply)            .position(x: size.width * 0.5, y: size.height * metrics.ruleCentre)            .accessibilityHidden(true)    }    /// The name, in the text serif — the face an object's name is set in    /// everywhere else in the kit, at its text optical size rather than the    /// display cut, because this is a caption on a card and not a title.    /// Whole words, cut at a word, never mid-word (the card-text rule).    private func printedName(size: CGSize) -> some View {        let width = size.width * (1 - (metrics.contentInset + metrics.contentInset))        let set = Self.printedName(name, theme: theme, width: size.width)        return Text(set.words)            .font(theme.type.title(set.size))            .foregroundStyle(PrintInk.dark.color.opacity(Double(ToolCardKnobs.toolCardNameInkOpacity)))            .blendMode(.multiply)            .lineLimit(1)            .frame(width: width)            .multilineTextAlignment(.center)            .position(x: size.width * 0.5, y: size.height * metrics.nameCentre)            .accessibilityHidden(true)    }}/// The sizes, counts and timings ToolCard draws with: Swift's own, beside/// their reader — a theme sets only its tokens (`scale.tokens`).enum ToolCardKnobs {    static let toolCardAspect: CGFloat = 0.75    /// A person's print against the object's square.    static let toolCardFaceFraction: CGFloat = 0.82    static let toolCardContentInset: CGFloat = 0.0625    static let toolCardFlatNameLines = 2    /// How small a card's name may set, as a share of its size, before a    /// word is cut: one long word ("Subscriptions") stands whole.    static let nameFloor: CGFloat = 0.62    static let toolCardNameCentre: CGFloat = 0.838    static let toolCardNameFraction: CGFloat = 0.105    static let toolCardNameInkOpacity: CGFloat = 0.9    static let toolCardObjectCentre: CGFloat = 0.4    static let toolCardObjectFraction: CGFloat = 0.78    static let toolCardObjectMaxHeightFraction: CGFloat = 0.66    static let toolCardRuleOpacity: CGFloat = 0.34    static let toolCardShadowBlurFraction: CGFloat = 0.03    static let toolCardShadowDropFraction: CGFloat = 0.022    static let toolCardShadowOpacity: CGFloat = 0.34    static let toolCardSurfaceShadowOpacity: CGFloat = 0.18    static let toolCardSurfaceShadowRadiusFraction: CGFloat = 0.045    static let toolCardSurfaceShadowYFraction: CGFloat = 0.028}extension ToolCardMetrics {    /// How far the stock's shadow reaches past its edge, at `width`: a    /// picture of a tile drawn this much larger on every side holds it whole.    static func shadowReach(width: CGFloat) -> CGFloat {        width * (ToolCardKnobs.toolCardSurfaceShadowRadiusFraction * 2 + ToolCardKnobs.toolCardSurfaceShadowYFraction)    }}// MARK: - A person's card/// What a person's own card (Me) stands in the object's place: their print/// when one is set (decoded before the card is drawn, so a card drawn once/// into a picture carries it), else their initials on a print.public struct HomeFace: Equatable, @unchecked Sendable {    public let name: String    public let picture: CGImage?    public let seed: String    /// The imageset Home's board names (`picture`), printed in the window    /// when there is neither a picture nor a name to print: nobody is chosen    /// as you yet, or the app has no "you".    public var object: String? = nil    public init(name: String, picture: CGImage?, seed: String, object: String? = nil) {        self.name = name        self.picture = picture        self.seed = seed        self.object = object    }}/// The print of `HomeFace`, `width` across: a white-bordered square, the/// picture or the initials in its window. Plain shapes only, so a card drawn/// once into a picture off screen (`FanPrints`) carries it.struct HomeFacePrint: View {    @Environment(\.theme) private var theme    let face: HomeFace    let width: CGFloat    var body: some View {        let border = width * HomeFaceKnobs.border        ZStack {            Rectangle().fill(theme.colors.paper.color)            ZStack {                Rectangle().fill(theme.sheet(.cream))                if let picture = face.picture {                    Image(decorative: picture, scale: 1).resizable().scaledToFill()                } else if CardPerson.initials(face.name) == nil, let object = face.object.flatMap(CottonMedia.image) {                    object.resizable().scaledToFit().padding(width * HomeFaceKnobs.border)                        .accessibilityHidden(true)                } else {                    Text(CardPerson.initials(face.name) ?? "")                        .font(theme.type.title(width * CardObjectKnobs.cardPrintInitialsTypeFraction))                        .foregroundStyle(theme.print(.pencil))                        .lineLimit(1)                        // A picture of the name beside it, never read as a word.                        .accessibilityHidden(true)                }            }            .frame(width: width - border * 2, height: width - border * 2)            .clipped()        }        .frame(width: width, height: width)        .shadow(color: .black.opacity(0.18), radius: width * 0.03, y: width * 0.015)    }}enum HomeFaceKnobs {    /// The print's white border against its width.    static let border: CGFloat = 0.06}