Cotton code
53 lines · 2.5 KB · SwiftRaw
// The colours of the book reader's three faces and of its three pencils.//// The book reader (CottonUI's `BookReaderScreen`) reads a book in one of// three faces the owner's coordinator fixed on 4 Nov 2026 from the pictures// picked for Cotton Books (`books7/reader-paper`, `reader-sepia`,// `reader-night`): Paper, a warm cream; Sepia, a warm parchment lighter// than the picture's kraft; Night, a warm near-black. Each is a whole: its// ground, its ink, its secondary ink (the running head, the page number,// the bar's words), and its hairline, which is the ink at a share// (`hairline`). The pencils a passage is underlined in (`books7/selection`)// are red, yellow and teal. A material is NOT a palette role: it is the// colour of a thing, read off the reference the way a paper's dye is read// off its photograph (`PaperDye`), and it does not flip with the theme.// `PaletteGuardTests` exempts this file from the CHANNELS sweep for that// sentence and no other; it writes no hex and names nothing.import SwiftUI/// The book reader's materials: each face's ground and inks, and the pencils.public enum BookFaceMaterial: String, CaseIterable, Sendable {    case paperGround, paperInk, paperSecondary    case sepiaGround, sepiaInk, sepiaSecondary    case nightGround, nightInk, nightSecondary    case pencilRed, pencilYellow, pencilTeal    public var colour: Color {        let (red, green, blue) = channels        return Color(red: red, green: green, blue: blue)    }    /// The colour's channels, 0 to 1: what a web page's colour is made of    /// where SwiftUI's colour does not reach (the EPUB's own page).    public var channels: (Double, Double, Double) {        switch self {        case .paperGround: (0.953, 0.918, 0.855)        case .paperInk: (0.165, 0.141, 0.125)        case .paperSecondary: (0.478, 0.431, 0.384)        case .sepiaGround: (0.914, 0.851, 0.718)        case .sepiaInk: (0.227, 0.176, 0.122)        case .sepiaSecondary: (0.541, 0.463, 0.341)        case .nightGround: (0.106, 0.102, 0.094)        case .nightInk: (0.847, 0.812, 0.749)        case .nightSecondary: (0.549, 0.518, 0.471)        case .pencilRed: (0.706, 0.263, 0.184)        case .pencilYellow: (0.851, 0.647, 0.125)        case .pencilTeal: (0.184, 0.498, 0.478)        }    }    /// How much of a face's ink its hairline is: a fifth on the dark face,    /// where a thinner share would vanish, else 15 %.    public static func hairline(dark: Bool) -> Double { dark ? 0.20 : 0.15 }}