// What the Cinemas faces share (the Picture House, 4 Nov 2026): a painted // layer laid by its catalogue name, the red enamel PROGRESS STRIP and the // ticket STUB. The film's one-sheet (`FilmPosterFace`) and the episode's // lobby card (`EpisodeLobbyFace`) lay the same two paintings // (`progress-strip`, `stub` and `stub-shadow`, imported once by // `scripts/import-cinemas-materials.py`), each where its own object's box // places them; what is drawn on the paint is the same, so it is drawn here // once. The knobs below are the paintings' own (`cinemas14-materials`' // `layout.json`: the strip's `nineSliceInsets`, the stub's `stampLiveType` // and `dateLiveType`); where each is laid is its face's. import CottonPaper import CottonValues import SwiftUI enum CinemaPartsKnobs { // THE PROGRESS STRIP's painting, a 9-slice across (`nineSliceInsets`: // its rounded caps 26 pixels each, never stretched), squeezed to the // height it is laid at. static let strip = CGSize(width: 1402, height: 49) static let stripCap: CGFloat = 26 // THE STUB's painting, its shadow 64 of its own pixels past it, and its // live type in its own pixels (`stampLiveType`, `dateLiveType`): each's // middle, size and turn, and the room each is set in along its line. static let stubPainted = CGSize(width: 1439, height: 913) static let stubShadowReach: CGFloat = 64 static let stamp = CGPoint(x: 690, y: 350) static let stampSize: CGFloat = 170 static let stampRoom: CGFloat = 1000 static let day = CGPoint(x: 735, y: 600) static let daySize: CGFloat = 105 static let dayRoom: CGFloat = 1000 static let stubTurn: Double = -9.5 } /// A painted layer, by its catalogue name, at the scale it was painted for; /// nothing where this build carries no pictures. struct CinemaPainted: View { let name: String var body: some View { if let image = CottonMedia.image(name, scale: 3) { image.resizable().interpolation(.high).accessibilityHidden(true) } } } extension View { /// This view laid at `rect` of its object's box, in the box's pixels, /// scaled by `s`. func cinemaLaid(_ rect: CGRect, _ s: CGFloat, alignment: Alignment = .center) -> some View { frame(width: rect.width * s, height: rect.height * s, alignment: alignment) .offset(x: rect.minX * s, y: rect.minY * s) } } /// The red strip laid at `rect` of its object's box: its whole length the /// enamel taken down, its first `share` the enamel itself; tagged as the /// card's state, said as `said`. struct CinemaStrip: View { let rect: CGRect let share: Double let said: String let identifier: String let s: CGFloat var body: some View { ZStack(alignment: .topLeading) { CinemaNineStrip(width: rect.width, height: rect.height, s: s) .colorMultiply(CinemasMaterial.track.colour) CinemaNineStrip(width: rect.width * CGFloat(share), height: rect.height, s: s) } .frame(width: rect.width * s, height: rect.height * s, alignment: .topLeading) .contentShape(Rectangle()) .accessibilityElement() .accessibilityLabel(said) .accessibilityIdentifier(identifier) .facePart(.state) .offset(x: rect.minX * s, y: rect.minY * s) } } /// The strip's painting laid `width` by `height` of its object's pixels: its /// rounded caps kept their width (a third of a short strip's each), its /// middle stretched between them, the whole squeezed to the height. struct CinemaNineStrip: View { let width: CGFloat let height: CGFloat let s: CGFloat var body: some View { let knobs = CinemaPartsKnobs.self let cap = min(knobs.stripCap, width / 3) let middle = knobs.strip.width - 2 * knobs.stripCap ZStack(alignment: .topLeading) { piece(from: 0, of: knobs.stripCap, at: 0, wide: cap) piece(from: knobs.stripCap, of: middle, at: cap, wide: width - 2 * cap) piece(from: knobs.strip.width - knobs.stripCap, of: knobs.stripCap, at: width - cap, wide: cap) } .frame(width: max(0, width) * s, height: height * s, alignment: .topLeading) } /// The painting's columns from `from`, `of` wide, laid at `at`, `wide`. private func piece(from: CGFloat, of: CGFloat, at: CGFloat, wide: CGFloat) -> some View { let knobs = CinemaPartsKnobs.self let across = wide / of * s return CinemaPainted(name: "progress-strip") .frame(width: knobs.strip.width * across, height: height * s) .offset(x: -from * across) .frame(width: max(0, wide) * s, height: height * s, alignment: .leading) .clipped() .offset(x: at * s) } } /// The ticket stub laid at `rect` of its object's box, its shadow under it, /// stamped and dated along its own tilt; tagged as the card's done. struct CinemaStub: View { let rect: CGRect let stamp: String let day: String? let identifier: String let s: CGFloat var body: some View { let knobs = CinemaPartsKnobs.self let k = rect.width / knobs.stubPainted.width let reach = knobs.stubShadowReach * k ZStack(alignment: .topLeading) { CinemaPainted(name: "stub-shadow").cinemaLaid(rect.insetBy(dx: -reach, dy: -reach), s) ZStack(alignment: .topLeading) { CinemaPainted(name: "stub") typed(stamp, at: knobs.stamp, size: knobs.stampSize, room: knobs.stampRoom, ink: CinemasMaterial.stamp.colour, k: k) if let day { typed(day, at: knobs.day, size: knobs.daySize, room: knobs.dayRoom, ink: CinemasMaterial.ink.colour, k: k) } } .frame(width: rect.width * s, height: rect.height * s, alignment: .topLeading) .contentShape(Rectangle()) .accessibilityElement(children: .ignore) .accessibilityLabel([stamp, day].compactMap { $0 }.joined(separator: ShellLines.line("cards", "join"))) .accessibilityIdentifier(identifier) .facePart(.done) .offset(x: rect.minX * s, y: rect.minY * s) } } /// `words` typed centred on `at` of the stub's own pixels, along its tilt. private func typed(_ words: String, at: CGPoint, size: CGFloat, room: CGFloat, ink: Color, k: CGFloat) -> some View { Text(words) .font(CottonFonts.type(size * k * s)) .foregroundStyle(ink) .lineLimit(1) .minimumScaleFactor(0.5) .frame(width: room * k * s, height: size * 1.4 * k * s) .rotationEffect(.degrees(CinemaPartsKnobs.stubTurn)) .position(x: at.x * k * s, y: at.y * k * s) .accessibilityHidden(true) } }