// The ALBUM as a SLIDE CAROUSEL TRAY (Cotton Photos, 12 Nov 2026; the // coordinator's brief for the photos-mac lane): a round projector tray of // charcoal plastic lying on the darkroom bench (`FaceGround.darkroomBench`), // its slides standing in its slots, a few of them taken out and laid on the // bench in front of it. No paper but the label: a tray is plastic, a slide's // mount is plastic, and only the round label pressed on its hub is paper // (the owner: paper only where the real thing is paper). Nothing is painted yet: // the tray, its slots and the mounts are drawn from `PhotosMaterial`'s // colours; a painted tray replaces them as the album board's paint did. // The face draws live what the album decides: // // a slide's top edge in a slot for each photo the album holds, from the // tray's notch round, eighty slots at most: an album of twelve fills // twelve, a big album fills the tray; // up to three of its prints as slides laid on the bench across the tray's // front, the cover first, largest, in the middle and on top, the other two // under it to either side; fewer prints leave the bench bare, never a // stand-in slide; // the round paper label on the hub: the album's name (three lines at most, // set smaller before it is cut) and under it how many photos it holds and // its days. // // Every word is the core's (`DeckCard`): the name (`title`), the count // (`count`) and the days (`span`); the prints are the album's own rows the // deck reads for its card (`DeckCard.prints`, the cover named by `photo` // first). Stepped by a tap, it cuts (`FaceStep.cut`). import CottonPaper import CottonValues import SwiftUI enum AlbumCarouselFaceKnobs { /// The face's room, its width over its height: the tray above, the /// slides laid on the bench across its front. static let aspect: CGFloat = 0.8 /// The face in the card's room: the most of its width and height. static let fill: CGFloat = 0.97 // THE TRAY, as shares of the face's width: its diameter and its middle. static let tray: CGFloat = 0.94 static let trayMiddle = CGPoint(x: 0.5, y: 0.5) /// The slot ring's inner and outer edge, the hub's edge and the label's, /// as shares of the tray's radius. static let slotsInner: CGFloat = 0.6 static let slotsOuter: CGFloat = 0.93 static let hub: CGFloat = 0.55 static let label: CGFloat = 0.45 /// A carousel holds eighty slides. static let slots = 80 /// The slot the notch stands at, where the first slide goes: twelve /// o'clock, the round then running clockwise. static let notch: Double = -90 /// A slide's top edge in its slot, as a share of the slot's width. static let slideEdge: CGFloat = 0.42 // A SLIDE'S MOUNT: square, its corners rounded, its window a 3:2 // landscape (a 35 mm frame in a 50 mm mount), as shares of its side. static let mountCorner: CGFloat = 0.07 static let window = CGSize(width: 0.72, height: 0.48) /// A slide's shadow on the bench, as a share of its side. static let slideShadow: CGFloat = 0.05 /// The type on the label, as shares of the face's width: print on an /// object scales with the object, never with Dynamic Type. static let nameSize: CGFloat = 0.05 static let factsSize: CGFloat = 0.034 static let nameLines = 3 static let nameLeast: CGFloat = 0.7 static let lineGap: CGFloat = 0.008 } /// One of the bench's three places for a slide taken out of the tray: its /// middle, as shares of the face's width and height, its side as a share of /// the face's width, and how far it is turned. public struct SlidePlace: Equatable, Sendable { public var x: CGFloat public var y: CGFloat public var side: CGFloat public var turn: Double /// The three places, the cover's first, in the order the album's prints /// fill them: a fourth would hang off the card's foot under the cover's /// shadow (12 Nov 2026). public static let all = [ SlidePlace(x: 0.5, y: 0.84, side: 0.36, turn: -3), SlidePlace(x: 0.2, y: 0.86, side: 0.29, turn: -11), SlidePlace(x: 0.8, y: 0.85, side: 0.29, turn: 8), ] /// The order the places are laid in, back to front: the cover last, on top. public static let stacking = [1, 2, 0] } /// What the carousel shows of an album. public enum CarouselSlides { /// The prints laid on the bench: the cover first, then the album's /// others as it holds them, at most one for each place. public static func shown(_ card: DeckCard) -> [String] { Array(AlbumPrints.ordered(card.prints ?? [], cover: card.text("photo")).prefix(SlidePlace.all.count)) } /// How many slots hold a slide: the photos the album holds, as the core /// counts them ("1,204" reads 1204), the tray's eighty at most. public static func filled(_ card: DeckCard) -> Int { let number = card.text("count").flatMap { Int($0.filter(\.isNumber)) } ?? 0 return min(max(number, 0), AlbumCarouselFaceKnobs.slots) } /// The angle, in degrees, of slot `index`'s middle, clockwise from the notch. public static func angle(of index: Int) -> Double { AlbumCarouselFaceKnobs.notch + 360 * (Double(index) + 0.5) / Double(AlbumCarouselFaceKnobs.slots) } } public struct AlbumCarouselFace: View { let card: DeckCard public init(card: DeckCard) { self.card = card } public var body: some View { let knobs = AlbumCarouselFaceKnobs.self GeometryReader { box in let width = min(box.size.width * knobs.fill, box.size.height * knobs.fill * knobs.aspect) let size = CGSize(width: width, height: width / knobs.aspect) CarouselOnBench(card: card, size: size) .frame(width: size.width, height: size.height) .frame(width: box.size.width, height: box.size.height) } .accessibilityElement(children: .contain) .accessibilityIdentifier("album-carousel") } } /// The tray with its slides and its label, and the slides laid in front of it. private struct CarouselOnBench: View { let card: DeckCard let size: CGSize var body: some View { let knobs = AlbumCarouselFaceKnobs.self let w = size.width let diameter = knobs.tray * w let middle = CGPoint(x: knobs.trayMiddle.x * w, y: knobs.trayMiddle.y * w) let prints = CarouselSlides.shown(card) ZStack(alignment: .topLeading) { Tray(filled: CarouselSlides.filled(card), diameter: diameter) .frame(width: diameter, height: diameter) .position(middle) .accessibilityHidden(true) HubLabel(card: card, diameter: knobs.label * diameter, face: w) .position(middle) ForEach(SlidePlace.stacking, id: \.self) { index in if index < prints.count { let place = SlidePlace.all[index] Slide(key: prints[index], side: place.side * w) .rotationEffect(.degrees(place.turn)) .position(x: place.x * w, y: place.y * size.height) .facePart(.picture) } } } .frame(width: w, height: size.height, alignment: .topLeading) } } /// The tray seen from above: its shadow on the bench, its outer wall, the /// ring of eighty slots with a slide's top edge in each filled one, the /// notch where the round starts, and its hub. private struct Tray: View { let filled: Int let diameter: CGFloat var body: some View { let knobs = AlbumCarouselFaceKnobs.self Canvas { context, size in let r = min(size.width, size.height) / 2 let c = CGPoint(x: size.width / 2, y: size.height / 2) func ring(_ radius: CGFloat) -> Path { Path(ellipseIn: CGRect(x: c.x - radius, y: c.y - radius, width: 2 * radius, height: 2 * radius)) } // Its shadow on the bench, under the safelight from the upper left. var shadow = context shadow.addFilter(.blur(radius: r * 0.05)) shadow.translateBy(x: r * 0.03, y: r * 0.05) shadow.fill(ring(r), with: .color(.black.opacity(0.6))) // The outer wall, moulded charcoal, lit at its upper left rim. context.fill(ring(r), with: .radialGradient( Gradient(colors: [PhotosMaterial.trayLit.colour, PhotosMaterial.tray.colour]), center: CGPoint(x: c.x - r * 0.3, y: c.y - r * 0.35), startRadius: 0, endRadius: r * 1.4)) context.stroke(ring(r - 0.6), with: .color(PhotosMaterial.trayLit.colour.opacity(0.8)), lineWidth: 1.2) // The slot ring's recess. let outer = knobs.slotsOuter * r let inner = knobs.slotsInner * r var recess = ring(outer) recess.addPath(ring(inner)) context.fill(recess, with: .color(PhotosMaterial.trayRecess.colour), style: FillStyle(eoFill: true)) // The dividers between the slots, and a slide's top in each filled one. for index in 0.. DeckCard { var card = DeckCard(face: "album.carousel", corner: nil, pressing: false, pace: nil, plate: nil, fields: fields) card.prints = prints return card } /// A weekend away: more prints than the bench takes, the lake its cover. public static let weekend = album([ "title": .text("Weekend in Kelmoor"), "count": .text("23"), "span": .text("Sun 26 Oct"), "photo": .text("kelmoor-lake"), ], prints: ["kelmoor-jetty", "kelmoor-lake", "portrait", "verandah", "waterfall", "verandah-wide"]) /// An afternoon's two prints: two slides out, two in the tray. public static let two = album([ "title": .text("Tea at the hill house"), "count": .text("2"), "span": .text("Sat 17 Oct"), "photo": .text("verandah"), ], prints: ["verandah", "verandah-wide"]) /// A long name, and more photos than the tray holds: every slot full. public static let longName = album([ "title": .text("The long drive down the coast and the night at the lighthouse"), "count": .text("1,204"), "span": .text("Fri 2 Oct \u{2013} Sun 11 Oct"), "photo": .text("waterfall"), ], prints: ["waterfall", "kelmoor-jetty", "verandah-wide", "portrait", "kelmoor-lake"]) /// A new album with nothing in it yet: an empty tray, a bare bench. public static let empty = album([ "title": .text("Diwali"), "count": .text("0"), ], prints: []) }