// The reader's paper, in either light (`ReadLight`). By day the centred page // (owner, 29 Oct 2026: "it looks too much paper"): a plain warm cream with // the faintest grain (`reader-paper`, a fine even noise, no mottle), and // nothing drawn over it — no binding, no gutter, no page edges. By night the // lamp: the painted near-black tile (`reader-night`) lit by a soft warm pool // centred on the text block, falling off smoothly to the margins and the // corners — added to the paper, so its tooth shows through the light. The // tiles are made by `scripts/import-reader-materials.py`; the pool is drawn. // Where a build carries no pictures, each paper is its colour alone. import CottonPaper import SwiftUI enum ReadGroundKnobs { /// The lamp's pool: its centre on the screen (the text block's middle, /// which the page centres), and how far it reaches as a share of the /// screen's half-diagonal. static let poolCentre = UnitPoint(x: 0.5, y: 0.5) static let poolReach: CGFloat = 0.85 } struct ReadGround: View { let light: ReadLight var body: some View { switch light { case .page: ReaderMaterial.paper.colour case .lamp: lamp } } private var lamp: some View { let pool = ReaderMaterial.pool.colour return paper(ReaderMaterial.night.colour, tile: "reader-night") .overlay { EllipticalGradient( stops: [ .init(color: pool, location: 0), .init(color: pool.opacity(0.75), location: 0.2), .init(color: pool.opacity(0.42), location: 0.45), .init(color: pool.opacity(0.16), location: 0.72), .init(color: .clear, location: 1), ], center: ReadGroundKnobs.poolCentre, startRadiusFraction: 0, endRadiusFraction: ReadGroundKnobs.poolReach ) .blendMode(.plusLighter) } } /// The paper's colour with its tile repeated over it, where this build /// carries the pictures. @ViewBuilder private func paper(_ colour: Color, tile name: String) -> some View { if let tile = CottonMedia.image(name, scale: 3) { colour.overlay(tile.resizable(resizingMode: .tile)) } else { colour } } }