Cotton code
65 lines · 2.8 KB · SwiftRaw
// A specimen drawn: the one way a face is drawn from its specimen alone (Loom,// 28 Oct 2026). The face is handed the specimen's card, its fixture picture// drawn from the bundled fixtures (`FixturePictures`), its long words cut by// the plain cutter (`PlainPageCutter`) and no taps, in Cotton's own look// (`Theme.paper`). It is the card as the phone's deck draws its front card:// the face on the paper it names, the deck's sheets under it (a paper face's;// a face on a ground of its own lies alone), the part the specimen selects// ringed (`selectedFacePart`). The Loom app's// face screen shows it, and `SpecimenShot` renders it for the face shots and// the Loom app's tests, so what is reviewed on the phone and what the tests// prove are the same drawing.import CottonFacesimport CottonPaperimport SwiftUIpublic struct SpecimenCard: View {    /// The longest side a specimen's picture is asked for at, in points.    public static let pictureEdge: CGFloat = 420    let face: Face    let specimen: Specimen    public init(_ face: Face, _ specimen: Specimen) {        self.face = face        self.specimen = specimen    }    public var body: some View {        ZStack(alignment: .topLeading) {            // The deck's sheets are paper, and lie on the paper ground; a            // face on a ground of its own lies there alone, its stack the            // per-tool ground's to say.            if Self.ground(of: face) == .paper {                CardSheetsUnder(count: CardPaperKnobs.under.count, stock: FaceRegistry.sheetsUnder(face.id, pace: specimen.card.pace))            }            drawnFace        }        .environment(\.facePictureDrawer, FixturePictures.drawer)        .environment(\.facePictureAspect, FixturePictures.aspect)        .environment(\.facePictureTint, FixturePictures.tint)        .environment(\.selectedFacePart, specimen.selected)        .environment(\.faceOpened, specimen.opened)        .environment(\.faceTurnedOver, specimen.turned)        .environment(\.facePageCutter, PlainPageCutter())        .themed(.paper)    }    /// The face, under the player's word where the specimen names one.    @ViewBuilder private var drawnFace: some View {        let drawn = face.view(specimen.card, picture: specimen.picture.map { FacePicture(key: $0, edge: Self.pictureEdge) }, taps: .none)        if let play = specimen.play {            // Its own player for each specimen, never the last one's.            drawn.environment(\.faceTrackPlayer, SpecimenPlaying.standing(play)).id(specimen.name)        } else {            drawn        }    }    /// The ground `face` lies on, as its file declares it: what the card is    /// stood on.    public static func ground(of face: Face) -> FaceGround {        FaceRegistry.ground(face.id) ?? .paper    }}