// What the gauge faces share (the machine's dials, the quota's meter): their// knobs, and a gauge's numbers read off the card as the core gave them —// numbers, never words.importCottonValuesimportSwiftUIenumGaugeFacesKnobs {staticlet inset = EdgeInsets(top: 30, leading: 24, bottom: 22, trailing: 22)staticlet nameSize: CGFloat = 36/// The Mac under the name: at most this share of the card's width, and/// the room round it.staticlet artShare: CGFloat = 0.8staticlet artGap: CGFloat = 4staticlet factGap: CGFloat = 3staticlet tableSize: CGFloat = 12.5/// The longest label the facts' label column holds, in letters.staticlet labelLetters = 8/// The dials just under the table, and the foot's rule under them.staticlet dialGap: CGFloat = 10staticlet footGap: CGFloat = 10staticlet footHand: CGFloat = 22/// A machine's dial: its width over the card's, the scale's sweep in/// degrees, its brass bezel, the wash's band and inset, the ticks (every/// `dialMajor`th long), the needle and the hub, each a share of the dial.staticlet dialShare: CGFloat = 0.29staticlet dialSweep: Double = 250staticlet bezel: CGFloat = 0.075staticlet washBand: CGFloat = 0.08staticlet washInset: CGFloat = 0.17staticlet dialTicks = 20staticlet dialMajor = 5staticlet tickRadius: CGFloat = 0.36staticlet needleLength: CGFloat = 0.36staticlet needleWidth: CGFloat = 0.06staticlet hub: CGFloat = 0.13/// The Macs drawn, by a word of the model the card names; the desk Mac/// (a display over a Mac Studio) when it names none of them.staticlet macArt: [(model: String, art: String)] = [ ("mini", "face-art-mac-mini"), ("macbook", "face-art-laptop"), ("studio", "face-art-computer"), ]staticlet deskMac = "face-art-computer"/// A quota: its title, the meter's height over the card's width, its/// band and needle and hub as shares of its radius, its ticks (every/// `meterMajor`th long) and the room its marks stand in.staticlet quotaTitle: CGFloat = 18/// The pencil line under when it resets.staticlet underline: CGFloat = 1.2staticlet underlineOpacity: Double = 0.7staticlet underlineTurn: Double = -1.5staticlet quotaGap: CGFloat = 8staticlet meterHeight: CGFloat = 0.54staticlet meterBand: CGFloat = 0.3/// The band's wash: green at the low end through buff to red at the top.staticlet zoneWash: Double = 0.44staticlet meterNeedle: CGFloat = 0.05staticlet meterHub: CGFloat = 0.16staticlet meterTicks = 40staticlet meterMajor = 8staticlet markRoom: CGFloat = 22staticlet markSize: CGFloat = 11staticlet usedSize: CGFloat = 22staticlet leftSize: CGFloat = 16staticlet resetHand: CGFloat = 24/// The trend under it: its width over the card's, its height, a dot,/// the room its typed shares stand in, their size, and how many/// readings are all typed.staticlet trendShare: CGFloat = 0.6staticlet trendHeight: CGFloat = 52staticlet trendDot: CGFloat = 4.5staticlet trendLine: CGFloat = 1staticlet trendWash: Double = 0.16staticlet trendLabel: CGFloat = 16staticlet trendType: CGFloat = 11staticlet trendTypedAll = 4/// The scale's marks: every fifth of a hundred.staticlet marks = stride(from: 0, through: 100, by: 20).map { "\($0)" }}extensionDeckCard {/// A gauge part as the core gave it: a number, never words.publicfunc number(_ slot: String) -> Double? {guardcase .number(let value)? = fields[slot] else { returnnil }return value }/// How full a gauge is, nought to one: `used` of `limit` (of a hundred/// when there is none), or what `free` leaves of `limit`.publicvar gaugeShare: Double? {iflet used = number("used") {return min(1, max(0, used / (number("limit") ?? 100))) }iflet free = number("free"), let limit = number("limit"), limit > 0 {return min(1, max(0, 1 - free / limit)) }returnnil }}