// 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. import CottonPaper import CottonValues import CoreText import SwiftUI enum FilmPosterFaceKnobs { // 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. static let box = CGSize(width: 919, height: 1393) static let widest: CGFloat = 300 /// The most of the card's room the frame and what it carries take. static let fillWidth: CGFloat = 0.96 static let fillHeight: CGFloat = 0.94 /// Its shadow, 64 pixels past it on every side (`shadowOffset`). static let 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. static let aperture = CGRect(x: 35, y: 35, width: 848, height: 1202) static let apertureRadius: CGFloat = 30 static let 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. static let oneSheet = CGRect(x: 80, y: 150, width: 758, height: 420) static let oneSheetSize: CGFloat = 150 static let oneSheetLeast: CGFloat = 72 static let oneSheetShrink: CGFloat = 0.94 static let oneSheetStep: CGFloat = 1.08 static let 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. static let marquee = CGRect(x: 50, y: 1260, width: 819, height: 85) static let marqueeSize: CGFloat = 38 static let marqueeLeast: CGFloat = 28 static let marqueeShrink: CGFloat = 0.94 static let marqueeStep: CGFloat = 1.05 // THE PROGRESS STRIP (`progressRect`), laid from `progress-strip` // (`CinemaStrip`, its painting's knobs `CinemaPartsKnobs`). static let 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). static let 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. static let 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)), ] static let seasonPainted = CGSize(width: 1565, height: 663) static let seasonSize: CGFloat = 96 static let seasonRoom: CGFloat = 640 } /// How the one-sheet in its frame is set. public enum FilmPosterSetting { /// The related lists the deck counts for a series: its seasons, its /// episodes. public static let seasonsList = "film_season" public static let episodesList = "film_episode" /// The card is a series': its kind, the value stored under its facts. public static func series(_ card: DeckCard) -> Bool { card.stored["facts"] == "series" } /// The film is watched: its status, the value stored under its state. public static func watched(_ card: DeckCard) -> Bool { card.stored["state"] == "watched" } /// The film's length said from its minutes ("1 h 52", "48 min"); nil, /// none kept. public static func length(_ card: DeckCard) -> String? { guard let minutes = card.number("limit"), minutes > 0 else { return nil } let whole = Int(minutes.rounded()) if whole < 60 { return ShellLines.line("cards", "film.length_minutes", ["minutes": "\(whole)"]) } let over = whole % 60 return ShellLines.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. public static func share(_ card: DeckCard) -> Double? { guard !series(card), !watched(card), let at = card.number("used"), at > 0, let minutes = card.number("limit"), minutes > 0 else { return nil } return min(1, at / (minutes * 60)) } /// What the related list `id` counted, as the deck said it; nil, not /// counted or none. static func 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. public static func 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. public static func marquee(_ card: DeckCard) -> (lines: [String], size: CGFloat) { let knobs = FilmPosterFaceKnobs.self let 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.width var size = knobs.marqueeSize while HighlightPassageSetting.wide(whole, caslon(size)) > width, size * knobs.marqueeShrink >= knobs.marqueeLeast { size *= knobs.marqueeShrink } if HighlightPassageSetting.wide(whole, caslon(size)) <= width { return ([whole], size) } guard let 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. public static func oneSheet(_ card: DeckCard) -> (lines: [String], size: CGFloat) { let knobs = FilmPosterFaceKnobs.self guard let title = card.text("title")?.split(whereSeparator: \.isWhitespace).joined(separator: " ") else { return ([], knobs.oneSheetSize) } let room = knobs.oneSheet func 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 in 1...knobs.oneSheetLines { var size = knobs.oneSheetSize while !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.oneSheetSize while 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. public static func 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"). public static func 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. public static func 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'). public static func stub(_ card: DeckCard) -> (stamp: String, day: String?)? { guard !series(card) else { return nil } if converting(card) { return (ShellLines.line("cards", "film.stub_converting").uppercased(), nil) } guard watched(card) else { return nil } return (ShellLines.line("cards", "film.stub").uppercased(), card.dated.map(DayStamp.of)) } /// Libre Caslon as CoreText measures it. static func 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. static func reach(series: Bool) -> CGRect { let knobs = FilmPosterFaceKnobs.self guard 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. static func turned(_ rect: CGRect, by degrees: Double) -> CGRect { let angle = degrees * .pi / 180 let 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) } } public struct FilmPosterFace: View { let card: DeckCard /// The poster laid behind the aperture; nil types the one-sheet. var poster: Poster? public init(card: DeckCard, poster: Poster? = nil) { self.card = card self.poster = poster } public var body: some View { let knobs = FilmPosterFaceKnobs.self let 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. private struct FramedPoster: View { let card: DeckCard let poster: Poster? let s: CGFloat var body: some View { let knobs = FilmPosterFaceKnobs.self ZStack(alignment: .topLeading) { SeasonCards(card: card, s: s) CinemaPainted(name: "frame-shadow").cinemaLaid(knobs.shadow, s) if let 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) if let 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) if let 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. private struct PosterPart: View { let card: DeckCard let s: CGFloat var body: some View { let knobs = FilmPosterFaceKnobs.self Color.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. private struct OneSheet: View { let card: DeckCard let s: CGFloat var body: some View { let knobs = FilmPosterFaceKnobs.self let (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 in Text(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. private struct Marquee: View { let card: DeckCard let s: CGFloat var body: some View { let knobs = FilmPosterFaceKnobs.self let (lines, size) = FilmPosterSetting.marquee(card) VStack(spacing: 0) { ForEach(Array(lines.enumerated()), id: \.offset) { _, line in Text(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. private struct SeasonCards: View { let card: DeckCard let s: CGFloat var body: some View { let knobs = FilmPosterFaceKnobs.self let seasons = FilmPosterSetting.seasons(card) if !seasons.isEmpty { ZStack(alignment: .topLeading) { ForEach(Array(seasons.enumerated()), id: \.offset) { place, number in let 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.`). public enum FilmPosterFaceCatalogue { public static let stock: FaceStock = .own public static let ground: FaceGround = .velvet public static let 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, _ in FilmPosterFace(card: card, poster: picture) } static func 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. public static let 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. public static let 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. public static let 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. public static let 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. public static let 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. public static let 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. public static let 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. public static let 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. public static let 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)]) }