//! The logo — the constellation-C — as GEOMETRY, and the one place it is declared. //! //! The logo is the constellation-C and never a typographic "C." stand-in //! (AGENTS.md → Identity). It exists in two forms and they are one mark: //! //! * the ART — `assets/brand/logo-master.png`, amber french knots //! joined by steel-blue thread, the picture the owner picked in the 2026-08-09 //! icon round. Every RASTER form (the phone's app icon, the Mac's `.icns`, //! the Android densities) is derived from it, because the thread's texture is //! what makes it that picture and no vector carries texture. //! * the GEOMETRY below — the same twelve points and eighteen threads, written //! out. Every VECTOR form (the phone's launch screen, the Mac's menu-bar //! template, the OAuth pages the server renders, the site's SVGs) is drawn //! from these numbers, because a 22-point menu-bar icon downsampled from a //! 1024-pixel photograph of embroidery is a smudge. //! //! **They are held to each other by a guard, which is what makes this one //! source and not two that happen to agree today.** //! `scripts/__tests__/constellation-mark.test.ts` reads the emitted //! `mark.json` and the master PNG and asserts that every knot declared here is //! centred on an amber knot in the art and that every thread declared here runs //! over inked pixels of it. Change the art and that guard goes red until these //! numbers follow; change these numbers and it goes red until the art does. //! //! Before this file there were three drawings calling themselves the logo: the //! app icon's nine knots, a seven-star polyline the phone's splash and the site //! both drew, and a base64 PNG inlined in the OAuth page. The owner saw all three //! on 2026-09-10 and said so. //! //! Nothing in here is behaviour. It is data plus the total lookups over it. use crate::design::palette::GRAPHITE; /// One point of the logo, in [`VIEW_WIDTH`] × [`VIEW_HEIGHT`] units. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Point { pub x: f64, pub y: f64, pub kind: PointKind, } /// What a point IS — which decides whether it is drawn. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum PointKind { /// A french knot: an amber disc, drawn. Knot, /// A turn in the thread with no knot on it. Present in the art, and a /// renderer that treats one as a knot draws three dots the icon has not /// got. Turn, } impl PointKind { pub const fn as_str(self) -> &'static str { match self { PointKind::Knot => "knot", PointKind::Turn => "turn", } } } /// The width of the space the coordinates below are written in. /// /// It is the master art's own pixel grid (439 × 629, its trimmed ink box), so /// the guard can compare a declared coordinate with a pixel WITHOUT a scale /// factor in between — the one arithmetic step where a mistake would look like /// a match. pub const VIEW_WIDTH: f64 = 439.0; /// The height of that box. See [`VIEW_WIDTH`]. pub const VIEW_HEIGHT: f64 = 629.0; /// A knot's radius, in view units — measured off the master (15.5 px, and the /// same for all nine: the art draws one knot size). pub const KNOT_RADIUS: f64 = 15.5; /// The thread's width, in view units — measured off the master (13.5 px /// perpendicular, median over every segment away from a knot). pub const THREAD_WIDTH: f64 = 13.5; /// The amber a knot is worked in. /// /// The logo's own colour, not the palette's: it is the same amber wherever the /// mark is set, including on a page that carries none of Cotton's colours, so /// it is declared here rather than taking a palette slot. pub const KNOT_INK: &str = "#D9962E"; /// The steel-blue the thread is worked in — the brand's charcoal palette's /// accent, read from the record rather than written down twice. pub const THREAD_INK: &str = GRAPHITE.accent; /// The charcoal ground the logo is set on wherever it needs one (the icon /// tile, the favicon). Not an appearance: the brand's own fixed ground. pub const GROUND: &str = GRAPHITE.ground; /// The twelve points, in the order the guard reports them. /// /// Indices 0–8 are the nine knots, 9–11 the three turns; [`THREADS`] joins them /// by index. The numbers were read OFF the master (blob centroids for the /// knots, a coverage fit for the turns) rather than authored, which is why they /// are not round. pub const POINTS: [Point; 12] = [ // ── the nine knots, top to bottom ──────────────────────────────────── // 0 — the top of the C. Point { x: 234.7, y: 15.9, kind: PointKind::Knot }, // 1 — the C's upper terminal, top right. Point { x: 407.7, y: 93.0, kind: PointKind::Knot }, // 2 — the outer shoulder, top left. Point { x: 66.6, y: 93.0, kind: PointKind::Knot }, // 3 — the upper waist. Point { x: 93.1, y: 259.1, kind: PointKind::Knot }, // 4 — the lower waist. Point { x: 92.9, y: 385.1, kind: PointKind::Knot }, // 5 — the C's lower terminal, far right. Point { x: 422.7, y: 442.1, kind: PointKind::Knot }, // 6 — the outer hip, bottom left. Point { x: 64.3, y: 527.9, kind: PointKind::Knot }, // 7 — the lower right, under the terminal. Point { x: 388.2, y: 529.9, kind: PointKind::Knot }, // 8 — the foot of the C. Point { x: 248.2, y: 611.9, kind: PointKind::Knot }, // ── the three turns ────────────────────────────────────────────────── // 9 — the spine's apex: four threads meet at the far left and none of // them carries a knot. Drawing one here is the commonest way to get // this mark subtly wrong. Point { x: 0.0, y: 318.3, kind: PointKind::Turn }, // 10 — where the upper inner arc turns down toward the waist. Point { x: 232.7, y: 163.5, kind: PointKind::Turn }, // 11 — where the lower inner arc turns up toward the terminal. Point { x: 294.1, y: 497.0, kind: PointKind::Turn }, ]; /// The eighteen threads, as index pairs into [`POINTS`]. /// /// A thread is a straight run between two points; the logo's curves are made of /// them, which is why the turns exist. pub const THREADS: [(usize, usize); 18] = [ (0, 1), (0, 2), (0, 3), (2, 3), (2, 9), (3, 4), (3, 9), (3, 10), (1, 10), (4, 6), (4, 8), (4, 9), (4, 11), (5, 11), (5, 7), (6, 8), (6, 9), (7, 8), ]; /// The ink's true bounding box: every point grown by what is DRAWN on it — a /// knot by its radius, a bare turn by half the thread's width. /// /// Renderers map this box into the space they were given, so a round join at /// the apex (which sits on x = 0) is never clipped and the logo is never /// letterboxed by the empty margin a naive 0…VIEW box would carry. /// /// Returns `(min_x, min_y, max_x, max_y)`. pub fn content_bounds() -> (f64, f64, f64, f64) { let mut min_x = f64::MAX; let mut min_y = f64::MAX; let mut max_x = f64::MIN; let mut max_y = f64::MIN; for point in POINTS { let grow = match point.kind { PointKind::Knot => KNOT_RADIUS, PointKind::Turn => THREAD_WIDTH / 2.0, }; min_x = min_x.min(point.x - grow); min_y = min_y.min(point.y - grow); max_x = max_x.max(point.x + grow); max_y = max_y.max(point.y + grow); } (min_x, min_y, max_x, max_y) } /// How the logo is inked in a given rendering. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MarkInk<'a> { /// The knots' fill. pub knot: &'a str, /// The thread's stroke. pub thread: &'a str, } impl Default for MarkInk<'_> { fn default() -> Self { MarkInk { knot: KNOT_INK, thread: THREAD_INK } } } /// The logo as SVG elements — threads then knots, with no wrapping ``. /// /// `size` is the side of the square the caller wants it to fill; the logo is /// scaled to FIT that square by its [`content_bounds`] and centred in it, so a /// caller never has to know the logo is taller than it is wide. /// /// No ``, no ``, no external anything: the pages that inline this /// are served by a self-hosted server with no cottondb.com behind it, under a /// policy that would refuse an external image anyway. pub fn mark_inner(size: f64, ink: MarkInk<'_>) -> String { mark_inner_at(size, size, ink) } /// How much wider the ink is than it is tall — 0.71, so a caller that wants the /// logo 30 points tall wants it about 21 wide. /// /// It exists because "draw it in a square and letterbox" is what a page's CSS /// then has to undo: `height: 30px; width: auto` over a square viewBox renders /// a 21-point drawing inside a 30-point box, which reads as a logo that is too /// small and sitting slightly wrong. pub fn content_aspect() -> f64 { let (min_x, min_y, max_x, max_y) = content_bounds(); (max_x - min_x) / (max_y - min_y) } /// The same drawing, fitted to a RECTANGLE and centred in it. pub fn mark_inner_at(width: f64, height: f64, ink: MarkInk<'_>) -> String { let (min_x, min_y, max_x, max_y) = content_bounds(); let scale = (width / (max_x - min_x)).min(height / (max_y - min_y)); let offset_x = (width - (max_x - min_x) * scale) / 2.0 - min_x * scale; let offset_y = (height - (max_y - min_y) * scale) / 2.0 - min_y * scale; let at = |value: f64, offset: f64| format!("{:.2}", value * scale + offset); let mut out = String::new(); let mut threads = String::new(); for (from, to) in THREADS { let a = POINTS[from]; let b = POINTS[to]; threads.push_str(&format!( "M{} {}L{} {}", at(a.x, offset_x), at(a.y, offset_y), at(b.x, offset_x), at(b.y, offset_y) )); } out.push_str(&format!( "", threads, ink.thread, THREAD_WIDTH * scale )); for point in POINTS { if point.kind != PointKind::Knot { continue; } out.push_str(&format!( "", at(point.x, offset_x), at(point.y, offset_y), KNOT_RADIUS * scale, ink.knot )); } out } /// A complete standalone SVG of the logo on a transparent ground. pub fn mark_svg(size: f64, ink: MarkInk<'_>) -> String { format!( "{}", mark_inner(size, ink) ) } /// The logo on a rounded graphite tile — the shape the icon carries, for a page /// that wants the logo to read as the app's icon rather than as a bare mark. pub fn tile_svg(size: f64) -> String { format!( "\ \ {}", size * 0.22, mark_inner(size * 0.68, MarkInk::default()), inset = size * 0.16, ) } #[cfg(test)] #[path = "mark_tests.rs"] mod tests;