// The FILM as a ONE-SHEET in its BRASS-CORNERED LOBBY FRAME, hung on the// Picture House's curtain-red velvet under its one warm house light// (`FaceGround.velvet`; the coordinator's look for Cotton Cinemas, 4 Nov// 2026, after the pictures `cinemas13-house/film-a`, `film-b`, `film-c` and// `series-b`). The frame with its poster aperture and blank cream marquee,// its shadow, the red progress strip, the ticket stub and its shadow, the// season card and the velvet are PAINTED (`Media.xcassets`, imported by// `scripts/import-cinemas-materials.py`), each laid where the materials'// `layout.json` (`cinemas14-materials`) places it in the 919 x 1393 frame's// box, scaled by the drawn width over 919; the strip and the stub are the// Cinemas faces' own (`CinemaParts.swift`). The face draws live only what// the card decides://// the POSTER is the film's own picture, laid behind the frame's aperture;// a film kept without one shows a one-sheet typed there instead, its// title in Libre Caslon cream on a dark blue field, on one line taken// down until it fits, then on two balanced lines, past the least size cut.// the MARQUEE says the film ("The Harbour Lamp · 2019 · 1 h 52", its// length from its minutes) on one line taken down until it fits; past// the least size the title takes the first line alone and the rest goes// under it.// the PROGRESS STRIP, under the poster inside the marquee's top edge, for// a film part way through: its red filled as far as the resume point is// of the film's length, the rest the same enamel taken down.// the STUB, tucked at the frame's upper right corner once the film is// watched: stamped WATCHED, the day typed on its rule.// a SERIES (its kind `series`) wears the same frame with its season// cards fanned behind the top edge, "SEASON n" typed on each, the newest// at the back: as many as it has, three at most, the newest three; its// marquee says its seasons and episodes as the deck counted them.//// Tagged: the poster (`picture`), the marquee (`title`), the stub (`done`),// the strip (`state`), the season cards (`body`). Stepped by a tap, it cuts.// Print on an object scales with the object, never with Dynamic Type.//// What the card holds (the slots the Cinemas kit fills): `title`, `year`,// `photo` (the poster), `state` (stored: `watched` wears the stub stamped// WATCHED, `needs_mac` the stub stamped CONVERTING, dayless), `date`// (watched on), `used` (the resume point, seconds), `limit` (the length,// minutes), `facts` (stored: the kind, `series` fans the seasons), and the// deck's counts of the related `film_season` and `film_episode` lists.// Every word is the core's or a line: the face only sets them.importCottonPaperimportCottonValuesimportCoreTextimportSwiftUIenumFilmPosterFaceKnobs {// THE FRAME'S BOX every placement is in, in the paintings' pixels// (`layout.json`'s `frame`): the face draws the frame at most `widest`// points wide, and every place below is scaled by the drawn width over// the box's.staticlet box = CGSize(width: 919, height: 1393)staticlet widest: CGFloat = 300/// The most of the card's room the frame and what it carries take.staticlet fillWidth: CGFloat = 0.96staticlet fillHeight: CGFloat = 0.94/// Its shadow, 64 pixels past it on every side (`shadowOffset`).staticlet shadow = CGRect(x: -64, y: -64, width: 1047, height: 1521)// THE POSTER: the frame's aperture and its rounding (`posterAperture`,// `apertureRadius`), and a poster laid a hair past it, under the rails.staticlet aperture = CGRect(x: 35, y: 35, width: 848, height: 1202)staticlet apertureRadius: CGFloat = 30staticlet posterBleed: CGFloat = 4/// The typed one-sheet's title: its room on the field, its size and the/// least it is taken down to, the step it is taken down by, the step/// from one baseline to the next as a share of its size, the most lines.staticlet oneSheet = CGRect(x: 80, y: 150, width: 758, height: 420)staticlet oneSheetSize: CGFloat = 150staticlet oneSheetLeast: CGFloat = 72staticlet oneSheetShrink: CGFloat = 0.94staticlet oneSheetStep: CGFloat = 1.08staticlet oneSheetLines = 2// THE MARQUEE (`marqueeLiveTypeRect`): its words' size (the composite's)// and the least they are taken down to, the step, and the step from one// baseline to the next where it takes two lines.staticlet marquee = CGRect(x: 50, y: 1260, width: 819, height: 85)staticlet marqueeSize: CGFloat = 38staticlet marqueeLeast: CGFloat = 28staticlet marqueeShrink: CGFloat = 0.94staticlet marqueeStep: CGFloat = 1.05// THE PROGRESS STRIP (`progressRect`), laid from `progress-strip`// (`CinemaStrip`, its painting's knobs `CinemaPartsKnobs`).staticlet progress = CGRect(x: 50, y: 1245, width: 819, height: 12)// THE STUB, tucked over the frame's upper right corner (the watched// composite's `stubRect`, in the frame's box; `CinemaStub` types it).staticlet stub = CGRect(x: 790, y: 7, width: 325, height: 206.2)// THE SEASON CARDS (`series`' `seasonInstances`, from its 600-pixel// frame into the frame's own box), back first, then left, then right:// each's rect and turn (clockwise), and the middle of its label in the// card's own pixels (`titleCentreInSource`); the label's size there.staticlet seasons: [(rect: CGRect, turn: Double, label: CGPoint)] = [ (CGRect(x: 30.6, y: -321.6, width: 857.7, height: 363), 0, CGPoint(x: 782, y: 108)), (CGRect(x: -91.9, y: -214.4, width: 765.8, height: 324.7), -10, CGPoint(x: 420, y: 108)), (CGRect(x: 260.4, y: -214.4, width: 765.8, height: 324.7), 10, CGPoint(x: 782, y: 108)), ]staticlet seasonPainted = CGSize(width: 1565, height: 663)staticlet seasonSize: CGFloat = 96staticlet seasonRoom: CGFloat = 640}/// How the one-sheet in its frame is set.publicenumFilmPosterSetting {/// The related lists the deck counts for a series: its seasons, its/// episodes.publicstaticlet seasonsList = "film_season"publicstaticlet episodesList = "film_episode"/// The card is a series': its kind, the value stored under its facts.publicstaticfunc series(_ card: DeckCard) -> Bool { card.stored["facts"] == "series" }/// The film is watched: its status, the value stored under its state.publicstaticfunc watched(_ card: DeckCard) -> Bool { card.stored["state"] == "watched" }/// The film's length said from its minutes ("1 h 52", "48 min"); nil,/// none kept.publicstaticfunc length(_ card: DeckCard) -> String? {guardlet minutes = card.number("limit"), minutes > 0else { returnnil }let whole = Int(minutes.rounded())if whole < 60 { returnShellLines.line("cards", "film.length_minutes", ["minutes": "\(whole)"]) }let over = whole % 60returnShellLines.line("cards", "film.length_hours", ["hours": "\(whole / 60)", "minutes": over < 10 ? "0\(over)" : "\(over)"]) }/// How far the progress strip is filled, nought to one: the resume point/// of the film's length, for a film part way through and not watched;/// nil, no strip.publicstaticfunc share(_ card: DeckCard) -> Double? {guard !series(card), !watched(card), let at = card.number("used"), at > 0,let minutes = card.number("limit"), minutes > 0else { returnnil }return min(1, at / (minutes * 60)) }/// What the related list `id` counted, as the deck said it; nil, not/// counted or none.staticfunc counted(_ card: DeckCard, _ id: String) -> CardRelatedCount? { card.related.first { $0.id == id && $0.count > 0 } }/// The marquee's facts after the title: a film's year and length, a/// series' seasons and episodes.publicstaticfunc facts(_ card: DeckCard) -> [String] {if series(card) {return [counted(card, seasonsList), counted(card, episodesList)].compactMap { $0?.said } }return [card.text("year"), length(card)].compactMap { $0 } }/// The marquee's words: the title and its facts, as the cards join/// words, on one line taken down until it fits; past the least size the/// title alone on the first line (cut with an ellipsis if it must be)/// and the facts under it. In the frame's pixels.publicstaticfunc marquee(_ card: DeckCard) -> (lines: [String], size: CGFloat) {let knobs = FilmPosterFaceKnobs.selflet title = card.text("title")?.split(whereSeparator: \.isWhitespace).joined(separator: " ")let facts = facts(card).joined(separator: ShellLines.line("cards", "join"))let whole = ([title].compactMap { $0 } + (facts.isEmpty ? [] : [facts])).joined(separator: ShellLines.line("cards", "join"))guard !whole.isEmpty else { return ([], knobs.marqueeSize) }let width = knobs.marquee.widthvar size = knobs.marqueeSizewhileHighlightPassageSetting.wide(whole, caslon(size)) > width, size * knobs.marqueeShrink >= knobs.marqueeLeast { size *= knobs.marqueeShrink }ifHighlightPassageSetting.wide(whole, caslon(size)) <= width { return ([whole], size) }guardlet title else { return (HighlightPassageSetting.lines(facts, font: caslon(size), width: width, limit: 1), size) }// Two lines: the size the larger of the two fits at, within the// marquee's height, no less than the least. size = min(knobs.marqueeSize, knobs.marquee.height / (2 * knobs.marqueeStep))let wider = { max(HighlightPassageSetting.wide(title, caslon($0)), HighlightPassageSetting.wide(facts, caslon($0))) }while wider(size) > width, size * knobs.marqueeShrink >= knobs.marqueeLeast { size *= knobs.marqueeShrink }let first = HighlightPassageSetting.lines(title, font: caslon(size), width: width, limit: 1)let second = facts.isEmpty ? [] : HighlightPassageSetting.lines(facts, font: caslon(size), width: width, limit: 1)return (first + second, size) }/// The typed one-sheet's title in Libre Caslon: on one line at the/// sheet's own size, taken down a step at a time to the least; then on/// two balanced lines from the sheet's size down again; past the least/// size cut with an ellipsis. In the frame's pixels.publicstaticfunc oneSheet(_ card: DeckCard) -> (lines: [String], size: CGFloat) {let knobs = FilmPosterFaceKnobs.selfguardlet title = card.text("title")?.split(whereSeparator: \.isWhitespace).joined(separator: " ") else {return ([], knobs.oneSheetSize) }let room = knobs.oneSheetfunc fits(_ size: CGFloat, lines count: Int) -> Bool {let lines = HighlightPassageSetting.lines(title, font: caslon(size), width: room.width, limit: .max)return lines.count <= count && CGFloat(lines.count) * size * knobs.oneSheetStep <= room.height }for count in1...knobs.oneSheetLines {var size = knobs.oneSheetSizewhile !fits(size, lines: count), size * knobs.oneSheetShrink >= knobs.oneSheetLeast { size *= knobs.oneSheetShrink }if fits(size, lines: count) {return (BookHardbackSetting.balanced(title, font: caslon(size), width: room.width, limit: count), size) } }var size = knobs.oneSheetSizewhile size * knobs.oneSheetShrink >= knobs.oneSheetLeast { size *= knobs.oneSheetShrink }return (HighlightPassageSetting.lines(title, font: caslon(size), width: room.width, limit: knobs.oneSheetLines), size) }/// The seasons a series' cards are typed with, in the order they are/// laid — the back card, the left, the right — the newest at the back:/// as many as it has, the newest three of more.publicstaticfunc seasons(_ card: DeckCard) -> [Int] {guard series(card), let count = counted(card, seasonsList)?.count else { return [] }let shown = Array(max(1, count - FilmPosterFaceKnobs.seasons.count + 1)...count)return [shown.last!] + shown.dropLast() }/// A season card's words ("SEASON 2").publicstaticfunc season(_ number: Int) -> String {ShellLines.line("cards", "film.season", ["n": "\(number)"]).uppercased() }/// The film waits for the Mac to convert it: the flag stored under its/// state ahead of its status.publicstaticfunc converting(_ card: DeckCard) -> Bool { card.stored["state"] == "needs_mac" }/// The stub's stamp and the day it is typed with: CONVERTING, no day,/// while the Mac converts it; once watched, WATCHED and the day; nil/// otherwise (and on a series').publicstaticfunc stub(_ card: DeckCard) -> (stamp: String, day: String?)? {guard !series(card) else { returnnil }if converting(card) { return (ShellLines.line("cards", "film.stub_converting").uppercased(), nil) }guard watched(card) else { returnnil }return (ShellLines.line("cards", "film.stub").uppercased(), card.dated.map(DayStamp.of)) }/// Libre Caslon as CoreText measures it.staticfunc caslon(_ size: CGFloat) -> CTFont {HighlightPassageSetting.caslon(size) }/// What the face reaches, in the frame's box: the frame's shadow, a/// film's stub (always kept room for, so a film's frame is the same/// size watched or not), a series' season cards as turned.staticfunc reach(series: Bool) -> CGRect {let knobs = FilmPosterFaceKnobs.selfguard series else { return knobs.shadow.union(knobs.stub) }return knobs.seasons.reduce(knobs.shadow) { $0.union(turned($1.rect, by: $1.turn)) } }/// The bounds of `rect` turned `degrees` about its middle.staticfunc turned(_ rect: CGRect, by degrees: Double) -> CGRect {let angle = degrees * .pi / 180let width = rect.width * abs(cos(angle)) + rect.height * abs(sin(angle))let height = rect.width * abs(sin(angle)) + rect.height * abs(cos(angle))return CGRect(x: rect.midX - width / 2, y: rect.midY - height / 2, width: width, height: height) }}publicstructFilmPosterFace<Poster: View>: View {let card: DeckCard/// The poster laid behind the aperture; nil types the one-sheet.var poster: Poster?publicinit(card: DeckCard, poster: Poster? = nil) {self.card = cardself.poster = poster }publicvar body: someView {let knobs = FilmPosterFaceKnobs.selflet reach = FilmPosterSetting.reach(series: FilmPosterSetting.series(card))GeometryReader { room in// The frame stands in the middle across, what it carries kept// inside the card either side of it; down, the whole is centred.let across = 2 * max(knobs.box.width / 2 - reach.minX, reach.maxX - knobs.box.width / 2)let s = min(knobs.widest / knobs.box.width, room.size.width * knobs.fillWidth / across, room.size.height * knobs.fillHeight / reach.height)FramedPoster(card: card, poster: poster, s: s) .frame(width: knobs.box.width * s, height: knobs.box.height * s, alignment: .topLeading) .offset(x: (room.size.width - knobs.box.width * s) / 2, y: (room.size.height - reach.height * s) / 2 - reach.minY * s) .frame(width: room.size.width, height: room.size.height, alignment: .topLeading) } .accessibilityElement(children: .contain) .accessibilityIdentifier("film-poster") }}/// The frame in its box, scaled by `s`: a series' season cards behind it,/// its shadow, the poster or the typed one-sheet, the frame, the strip, the/// marquee, the stub.privatestructFramedPoster<Poster: View>: View {let card: DeckCardlet poster: Poster?let s: CGFloatvar body: someView {let knobs = FilmPosterFaceKnobs.self ZStack(alignment: .topLeading) {SeasonCards(card: card, s: s)CinemaPainted(name: "frame-shadow").cinemaLaid(knobs.shadow, s)iflet poster {let bled = knobs.aperture.insetBy(dx: -knobs.posterBleed, dy: -knobs.posterBleed) poster .frame(width: bled.width * s, height: bled.height * s) .clipped() .accessibilityHidden(true) .offset(x: bled.minX * s, y: bled.minY * s) } else {OneSheet(card: card, s: s) }CinemaPainted(name: "frame").cinemaLaid(CGRect(origin: .zero, size: knobs.box), s)PosterPart(card: card, s: s)iflet share = FilmPosterSetting.share(card) {CinemaStrip(rect: knobs.progress, share: share, said: share.formatted(.percent.precision(.fractionLength(0))), identifier: "film-progress", s: s) }Marquee(card: card, s: s)iflet stub = FilmPosterSetting.stub(card) {CinemaStub(rect: knobs.stub, stamp: stub.stamp, day: stub.day, identifier: "film-stub", s: s) } } .frame(width: knobs.box.width * s, height: knobs.box.height * s, alignment: .topLeading) }}/// The aperture as the card's part: the poster, or the typed one-sheet.privatestructPosterPart: View {let card: DeckCardlet s: CGFloatvar body: someView {let knobs = FilmPosterFaceKnobs.selfColor.clear .contentShape(Rectangle()) .frame(width: knobs.aperture.width * s, height: knobs.aperture.height * s) .accessibilityElement() .accessibilityLabel(card.text("title") ?? "") .accessibilityIdentifier("film-poster-picture") .facePart(.picture)// Moved into place after it is tagged, so the region the deck// reads is where it stands. .offset(x: knobs.aperture.minX * s, y: knobs.aperture.minY * s) }}/// The one-sheet typed for a film kept without a poster: the dark blue/// field filling the aperture, the title set on it in cream.privatestructOneSheet: View {let card: DeckCardlet s: CGFloatvar body: someView {let knobs = FilmPosterFaceKnobs.selflet (lines, size) = FilmPosterSetting.oneSheet(card) ZStack(alignment: .topLeading) {RoundedRectangle(cornerRadius: knobs.apertureRadius * s, style: .continuous) .fill(CinemasMaterial.field.colour) .cinemaLaid(knobs.aperture, s) VStack(spacing: 0) {ForEach(Array(lines.enumerated()), id: \.offset) { _, line inText(line) .font(CottonFonts.caslon(size * s)) .lineLimit(1) .fixedSize() .frame(height: size * knobs.oneSheetStep * s) } } .foregroundStyle(CinemasMaterial.cream.colour) .frame(width: knobs.oneSheet.width * s, height: knobs.oneSheet.height * s, alignment: .top) .accessibilityHidden(true) .offset(x: knobs.oneSheet.minX * s, y: knobs.oneSheet.minY * s) } }}/// The marquee's words, centred on the cream strip.privatestructMarquee: View {let card: DeckCardlet s: CGFloatvar body: someView {let knobs = FilmPosterFaceKnobs.selflet (lines, size) = FilmPosterSetting.marquee(card) VStack(spacing: 0) {ForEach(Array(lines.enumerated()), id: \.offset) { _, line inText(line) .font(CottonFonts.caslon(size * s)) .lineLimit(1) .fixedSize() .frame(height: size * knobs.marqueeStep * s) } } .foregroundStyle(CinemasMaterial.ink.colour) .frame(width: knobs.marquee.width * s, height: knobs.marquee.height * s) .contentShape(Rectangle()) .accessibilityElement() .accessibilityLabel(lines.joined(separator: ShellLines.line("cards", "join"))) .accessibilityAddTraits(.isHeader) .accessibilityIdentifier("deck-title") .facePart(.title) .offset(x: knobs.marquee.minX * s, y: knobs.marquee.minY * s) }}/// A series' season cards fanned behind the frame's top edge, the newest at/// the back, each typed with its season.privatestructSeasonCards: View {let card: DeckCardlet s: CGFloatvar body: someView {let knobs = FilmPosterFaceKnobs.selflet seasons = FilmPosterSetting.seasons(card)if !seasons.isEmpty { ZStack(alignment: .topLeading) {ForEach(Array(seasons.enumerated()), id: \.offset) { place, number inlet laid = knobs.seasons[place]let k = laid.rect.width / knobs.seasonPainted.width ZStack(alignment: .topLeading) {CinemaPainted(name: "season-card")Text(FilmPosterSetting.season(number)) .font(CottonFonts.type(knobs.seasonSize * k * s)) .foregroundStyle(CinemasMaterial.ink.colour) .lineLimit(1) .minimumScaleFactor(0.5) .frame(width: knobs.seasonRoom * k * s, height: knobs.seasonSize * 1.4 * k * s) .position(x: laid.label.x * k * s, y: laid.label.y * k * s) .accessibilityHidden(true) } .frame(width: laid.rect.width * s, height: laid.rect.height * s, alignment: .topLeading) .rotationEffect(.degrees(laid.turn)) .offset(x: laid.rect.minX * s, y: laid.rect.minY * s) } } .contentShape(Rectangle()) .accessibilityElement(children: .ignore) .accessibilityLabel(seasons.sorted().map(FilmPosterSetting.season).joined(separator: ShellLines.line("cards", "join"))) .accessibilityIdentifier("film-seasons") .facePart(.body) } }}/// The one-sheet in its frame, by its id beside the film's video, and the/// films and series it is reviewed in: invented titles, an invented poster./// A day is said as the core says it (`weekday_date`); a related count as/// the deck says it (`opened.related.<table>`).publicenumFilmPosterFaceCatalogue {publicstaticlet stock: FaceStock = .ownpublicstaticlet ground: FaceGround = .velvetpublicstaticlet face = Face(id: "film.poster", specimens: [Specimen("poster", poster, picture: "poster-ferry"), Specimen("no-poster", noPoster),Specimen("half-watched", halfWatched, picture: "poster-ferry"), Specimen("watched", watched, picture: "poster-ferry"),Specimen("converting", converting),Specimen("series", series, picture: "poster-ferry"), Specimen("series-one-season", seriesOneSeason, picture: "poster-ferry"),Specimen("longest-title", longestTitle), Specimen("largest", largest), ], steps: .cut) { card, picture, _ inFilmPosterFace(card: card, poster: picture) }staticfunc film(_ status: String, _ fields: [String: RecordValue], kind: String = "film", related: [(String, String, Int)] = []) -> DeckCard {var card = DeckCard(face: "film.poster", corner: nil, pressing: false, pace: nil, plate: nil, fields: fields) card.stored["state"] = status card.stored["facts"] = kind card.related = related.map { CardRelatedCount(id: $0.0, said: $0.1, count: $0.2) }return card }/// Still to watch, its poster kept.publicstaticlet poster = film("want_to_watch", ["title": .text("Night Ferry"),"year": .text("2019"),"photo": .text("poster-ferry"),"state": .text("Want to watch"),"limit": .number(112),"date": .text("Add date"), ])/// No poster kept: the one-sheet typed.publicstaticlet noPoster = film("want_to_watch", ["title": .text("The Fog Bell"),"year": .text("2021"),"state": .text("Want to watch"),"limit": .number(98),"date": .text("Add date"), ])/// Half way through: the strip filled to its middle.publicstaticlet halfWatched = film("watching", ["title": .text("Night Ferry"),"year": .text("2019"),"photo": .text("poster-ferry"),"state": .text("Watching"),"used": .number(3360),"limit": .number(112),"date": .text("Add date"), ])/// Watched: the stub tucked at the corner, its day typed.publicstaticlet watched = film("watched", ["title": .text("Night Ferry"),"year": .text("2019"),"photo": .text("poster-ferry"),"state": .text("Watched"),"limit": .number(112),"date": .text("Wed 4 Nov"),"count": .number(4), ])/// Still converting on the Mac: no poster frame yet, the stub stamped/// CONVERTING with no day.publicstaticlet converting = film("needs_mac", ["title": .text("The Salt Road"),"year": .text("2020"),"state": .text("Converting on your Mac"),"limit": .number(104),"date": .text("Add date"), ])/// A series of three seasons: three cards, the third at the back.publicstaticlet series = film("watching", ["title": .text("Night Ferry"),"year": .text("2022"),"photo": .text("poster-ferry"),"state": .text("Watching"),"date": .text("Add date"), ], kind: "series", related: [("film_season", "3 seasons", 3), ("film_episode", "24 episodes", 24)])/// A series of one season: one card, at the back.publicstaticlet seriesOneSeason = film("want_to_watch", ["title": .text("Night Ferry"),"year": .text("2025"),"photo": .text("poster-ferry"),"state": .text("Want to watch"),"date": .text("Add date"), ], kind: "series", related: [("film_season", "1 season", 1), ("film_episode", "8 episodes", 8)])/// The longest title: the one-sheet on two lines, the marquee on two.publicstaticlet longestTitle = film("watching", ["title": .text("The Lamp-Keeper's Daughter and the Long Night on the Northern Coast"),"year": .text("2017"),"state": .text("Watching"),"used": .number(5400),"limit": .number(187),"date": .text("Add date"), ])/// The fullest card, drawn at every text size Loom has, the largest/// among them: a long series of seven seasons, its newest three dealt.publicstaticlet largest = film("watched", ["title": .text("The Lantern Coast and Other Stories of the Harbour Towns"),"year": .text("2014"),"state": .text("Watched"),"date": .text("Sun 1 Nov"), ], kind: "series", related: [("film_season", "7 seasons", 7), ("film_episode", "68 episodes", 68)])}