// The paper's arithmetic: the four canonical sizes, the inset, the corner, the // tilt — and the one hash the tilt is seeded from. // // THE DESIGN PRINCIPLE, from the spec and from the caps that proved it: an // object owns its lettering geometry as FRACTIONS OF ITS OWN SIZE, never as // fixed points. A cap's name is 0.205 of its side and reads at 28pt and at // 120pt; the todo card's label was 14pt whatever the card's width, which is why // the Mac's narrow column needed a second number. Everything here is a fraction // or a clamp of one, so a sheet at 120pt and the same sheet at 360pt are the // same design. // // EVERY VARIATION IS SEEDED BY THE RECORD'S ID. Tilt, edge wear, deckle: all of // them come out of `PaperNoise`, whose only input is the seed string. The same // record is the same piece of paper on every launch, on every device and in // every screenshot — "consistency in structure, variation in artifact", and // never jitter. import CoreGraphics import Foundation // THE NUMBERS LIVE IN THE THEME'S SCALE (`paper_*` keys): a face reads them // from the WORN theme — `RecordListSurfaceKnobs.paperGap`, `theme.scale.inset(forWidth:)`, // `theme.scale.radius(for:)`, `theme.scale.pageClearance(topInset:)` — never // from a static that reads the shipped theme. What stays here is the one pure // function the theme's arithmetic needs: the seeded tilt. public enum PaperMetrics { /// A sheet's tilt in degrees, a deterministic function of its seed, within /// ± `range` degrees (the theme's `paper_tilt_range_degrees`). Small on /// purpose: the reference pictures tilt by about a degree, and anything /// more reads as a scrapbook. public static func tilt(seed: String, range: Double) -> Double { let unit = PaperNoise.unit(seed: seed, salt: PaperNoise.tiltSalt) return (unit + unit) * range - range } }