Cotton code
70 lines · 2.7 KB · SwiftRaw
// The logo the front door needs.//// It is here rather than in `Chrome/` because it is not a design-system// primitive — 4c owns that folder, and this exists for the boot path and// the splash.import CottonKitimport SwiftUI/// The constellation-C, drawn.////// The logo is the constellation-C and never a typographic "C." stand-in. It is/// a shape rather than an image asset because the splash and the masthead/// need it at different sizes against one ground, and a vector is what makes/// those the same mark rather than two crops of one PNG.////// **The geometry is `CottonMark`'s and is not authored here.** This view drew/// seven stars on one open polyline until 2026-09-10 — a lookalike, not the/// mark: the app icon works NINE knots, joined by eighteen threads that cross,/// and turns the thread at three points that carry no knot. The owner saw the/// launch screen and the icon side by side and said they were different marks./// `CottonMark` is generated by `cotton-gen` from the icon's own art/// (`cotton-core — design/mark.rs`), so there is one drawing now and a guard/// holds it to the master PNG.public struct ConstellationMark: View {    private let ink: Color    public init(ink: Color = CottonColors.ink) {        self.ink = ink    }    public var body: some View {        Canvas { context, size in            let placement = CottonMark.placement(in: size)            // The threads first, so a knot always sits on top of what reaches            // it — the art's own order, and what keeps a join from showing            // through an amber disc.            var threads = Path()            for thread in CottonMark.threads {                threads.move(to: placement.at(CottonMark.points[thread.from]))                threads.addLine(to: placement.at(CottonMark.points[thread.to]))            }            context.stroke(                threads,                with: .color(ink.opacity(0.35)),                style: StrokeStyle(                    lineWidth: placement.threadWidth,                    lineCap: .round,                    lineJoin: .round                )            )            for point in CottonMark.points where point.isKnot {                let centre = placement.at(point)                let radius = placement.knotRadius                context.fill(                    Path(                        ellipseIn: CGRect(                            x: centre.x - radius,                            y: centre.y - radius,                            width: radius * 2,                            height: radius * 2                        )                    ),                    with: .color(ink)                )            }        }        .accessibilityHidden(true)    }}