// 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`).importCottonPaperimportCottonValuesimportSwiftUIenumAlbumCarouselFaceKnobs {/// The face's room, its width over its height: the tray above, the/// slides laid on the bench across its front.staticlet aspect: CGFloat = 0.8/// The face in the card's room: the most of its width and height.staticlet fill: CGFloat = 0.97// THE TRAY, as shares of the face's width: its diameter and its middle.staticlet tray: CGFloat = 0.94staticlet 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.staticlet slotsInner: CGFloat = 0.6staticlet slotsOuter: CGFloat = 0.93staticlet hub: CGFloat = 0.55staticlet label: CGFloat = 0.45/// A carousel holds eighty slides.staticlet slots = 80/// The slot the notch stands at, where the first slide goes: twelve/// o'clock, the round then running clockwise.staticlet notch: Double = -90/// A slide's top edge in its slot, as a share of the slot's width.staticlet 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.staticlet mountCorner: CGFloat = 0.07staticlet window = CGSize(width: 0.72, height: 0.48)/// A slide's shadow on the bench, as a share of its side.staticlet 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.staticlet nameSize: CGFloat = 0.05staticlet factsSize: CGFloat = 0.034staticlet nameLines = 3staticlet nameLeast: CGFloat = 0.7staticlet 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.publicstructSlidePlace: Equatable, Sendable {publicvar x: CGFloatpublicvar y: CGFloatpublicvar side: CGFloatpublicvar 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).publicstaticlet 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.publicstaticlet stacking = [1, 2, 0]}/// What the carousel shows of an album.publicenumCarouselSlides {/// The prints laid on the bench: the cover first, then the album's/// others as it holds them, at most one for each place.publicstaticfunc 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.publicstaticfunc filled(_ card: DeckCard) -> Int {let number = card.text("count").flatMap { Int($0.filter(\.isNumber)) } ?? 0return min(max(number, 0), AlbumCarouselFaceKnobs.slots) }/// The angle, in degrees, of slot `index`'s middle, clockwise from the notch.publicstaticfunc angle(of index: Int) -> Double {AlbumCarouselFaceKnobs.notch + 360 * (Double(index) + 0.5) / Double(AlbumCarouselFaceKnobs.slots) }}publicstructAlbumCarouselFace: View {let card: DeckCardpublicinit(card: DeckCard) {self.card = card }publicvar body: someView {let knobs = AlbumCarouselFaceKnobs.selfGeometryReader { box inlet 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.privatestructCarouselOnBench: View {let card: DeckCardlet size: CGSizevar body: someView {let knobs = AlbumCarouselFaceKnobs.selflet w = size.widthlet diameter = knobs.tray * wlet 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 inif 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.privatestructTray: View {let filled: Intlet diameter: CGFloatvar body: someView {let knobs = AlbumCarouselFaceKnobs.selfCanvas { context, size inlet r = min(size.width, size.height) / 2let 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 * rlet inner = knobs.slotsInner * rvar 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 in0..<knobs.slots {let wall = (knobs.notch + 360 * Double(index) / Double(knobs.slots)) * .pi / 180var divider = Path() divider.move(to: CGPoint(x: c.x + inner * cos(wall), y: c.y + inner * sin(wall))) divider.addLine(to: CGPoint(x: c.x + outer * cos(wall), y: c.y + outer * sin(wall))) context.stroke(divider, with: .color(PhotosMaterial.tray.colour), lineWidth: max(0.6, r * 0.012))guard index < filled else { continue }let middle = CarouselSlides.angle(of: index) * .pi / 180let pitch = 2 * .pi * (inner + outer) / 2 / CGFloat(knobs.slots)var edge = Path()let from = inner + (outer - inner) * 0.06let to = outer - (outer - inner) * 0.06 edge.move(to: CGPoint(x: c.x + from * cos(middle), y: c.y + from * sin(middle))) edge.addLine(to: CGPoint(x: c.x + to * cos(middle), y: c.y + to * sin(middle))) context.stroke(edge, with: .color(PhotosMaterial.mount.colour.opacity(0.92)), style: StrokeStyle(lineWidth: max(0.5, pitch * knobs.slideEdge), lineCap: .round)) }// The notch: a small bright tab on the wall at the first slot.let notch = knobs.notch * .pi / 180let tab = CGPoint(x: c.x + (outer + (r - outer) / 2) * cos(notch), y: c.y + (outer + (r - outer) / 2) * sin(notch)) context.fill(Path(ellipseIn: CGRect(x: tab.x - r * 0.025, y: tab.y - r * 0.025, width: r * 0.05, height: r * 0.05)), with: .color(PhotosMaterial.mount.colour.opacity(0.7)))// The hub, a raised disc, and its rim.let hub = knobs.hub * r context.fill(ring(inner * 0.99), with: .color(PhotosMaterial.tray.colour)) context.fill(ring(hub), with: .radialGradient(Gradient(colors: [PhotosMaterial.trayLit.colour, PhotosMaterial.trayRecess.colour]), center: CGPoint(x: c.x - hub * 0.4, y: c.y - hub * 0.45), startRadius: 0, endRadius: hub * 1.6)) context.stroke(ring(hub), with: .color(.black.opacity(0.45)), lineWidth: max(0.8, r * 0.01)) } }}/// One slide taken out of the tray: the picture in its mount's window, the/// moulded mount round it, its shadow on the bench.privatestructSlide: View {let key: String/// The mount's side, in points.let side: CGFloatvar body: someView {let knobs = AlbumCarouselFaceKnobs.selflet window = CGSize(width: knobs.window.width * side, height: knobs.window.height * side)let corner = knobs.mountCorner * side ZStack {RoundedRectangle(cornerRadius: corner) .fill(.black.opacity(0.55)) .blur(radius: knobs.slideShadow * side * 0.6) .offset(x: knobs.slideShadow * side * 0.5, y: knobs.slideShadow * side) .accessibilityHidden(true)FacePicture(key: key, edge: max(window.width, window.height)) .frame(width: window.width, height: window.height) .clipped()Rectangle() .path(in: CGRect(x: 0, y: 0, width: side, height: side)) .subtracting(Rectangle().path(in: CGRect( x: (side - window.width) / 2, y: (side - window.height) / 2, width: window.width, height: window.height))) .fill(LinearGradient(colors: [PhotosMaterial.mountLit.colour, PhotosMaterial.mount.colour], startPoint: .topLeading, endPoint: .bottomTrailing)) .clipShape(RoundedRectangle(cornerRadius: corner)) .overlay {RoundedRectangle(cornerRadius: corner) .strokeBorder(.black.opacity(0.18), lineWidth: max(0.5, side * 0.006)) } .overlay {// The window's moulded lip.Rectangle() .strokeBorder(.black.opacity(0.35), lineWidth: max(0.5, side * 0.008)) .frame(width: window.width, height: window.height) } .accessibilityHidden(true) } .frame(width: side, height: side) }}/// The round paper label pressed on the hub: the album's name, and under it/// its count and its days.privatestructHubLabel: View {let card: DeckCard/// The label's diameter, and the face's width, in points.let diameter: CGFloatlet face: CGFloatvar body: someView {let knobs = AlbumCarouselFaceKnobs.selflet facts = BoardPrints.facts(card)// The words keep to the square inside the round label.let room = diameter * 0.74 ZStack {Circle() .fill(PhotosMaterial.label.colour) .overlay(Circle().strokeBorder(.black.opacity(0.2), lineWidth: max(0.5, diameter * 0.008))) .shadow(color: .black.opacity(0.35), radius: diameter * 0.01, y: diameter * 0.008) .accessibilityHidden(true) VStack(spacing: knobs.lineGap * face) {iflet title = card.text("title") {Text(title) .font(CottonFonts.type(knobs.nameSize * face)) .lineLimit(knobs.nameLines) .minimumScaleFactor(knobs.nameLeast) .multilineTextAlignment(.center) .foregroundStyle(PhotosMaterial.type.colour) .accessibilityIdentifier("deck-title") .facePart(.title) }iflet facts {CarouselFacts(card: card, size: knobs.factsSize * face) .accessibilityRepresentation { Text(facts) } .accessibilityIdentifier("album-carousel-facts") } } .frame(width: room, height: room) } .frame(width: diameter, height: diameter) }}/// The label's second line: the count (the corner's) and the days (when),/// each its own part, joined as the core joins facts.privatestructCarouselFacts: View {let card: DeckCardlet size: CGFloatvar body: someView {let count = BoardPrints.count(card)let span = card.text("span") VStack(spacing: 0) {iflet count {Text(count).facePart(.corner) }iflet span {Text(span).facePart(.when) } } .font(CottonFonts.type(size)) .lineLimit(1) .minimumScaleFactor(0.6) .multilineTextAlignment(.center) .foregroundStyle(PhotosMaterial.type.colour) }}/// The slide carousel, by its id beside the album's board, and the albums it/// is reviewed in: invented pictures only.publicenumAlbumCarouselFaceCatalogue {publicstaticlet stock: FaceStock = .ownpublicstaticlet ground: FaceGround = .darkroomBenchpublicstaticlet face = Face(id: "album.carousel", specimens: [Specimen("weekend", weekend, picture: "kelmoor-lake"), Specimen("two", two, picture: "verandah"),Specimen("long-name", longName, picture: "waterfall"), Specimen("empty", empty), ], steps: .cut) { card, _, _ inAlbumCarouselFace(card: card) }staticfunc album(_ fields: [String: RecordValue], prints: [String]) -> DeckCard {var card = DeckCard(face: "album.carousel", corner: nil, pressing: false, pace: nil, plate: nil, fields: fields) card.prints = printsreturn card }/// A weekend away: more prints than the bench takes, the lake its cover.publicstaticlet 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.publicstaticlet 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.publicstaticlet 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.publicstaticlet empty = album(["title": .text("Diwali"),"count": .text("0"), ], prints: [])}