Brand
Brand light
The brand pattern, generated: one shape drawn three times in Red #DF0000 (0.85), Green #00FF29 (0.782) and Blue #1B1DFF (0.782), each shifted sideways, blurred and blended plus-lighter on Black. Seeded, in every variant the brand assets use.
Install
React apps get the React files; every other stack gets the web component.
npx spyglass-ds add brand-light<script type="module" src="/spyglass-ds/elements/brand-light.js"></script>Usage
Behind a hero, along a section's edge, beside a photo or under a search bar: a band, a field, a corner flow, strips down the sides, a tile, a close-up or a curved strip. A main mass and a smaller counterpart elsewhere.
Never
- Boxed in with hard edges in the middle of a layout: it flows in from edges and corners
- On any ground but Black
- As a screenshot or an image file: draw it from the generator
- Recolored, or animated in a loop
source="brand" (the default) cuts its windows from the brand's own heat map: seeds 0 up to the number of brand windows for a variant reproduce the brand assets' windows exactly, and higher seeds move and scale them a little. source="generated" builds a new heat map from the seed, the same way. The same seed draws the same light everywhere: in React, in the web component, in spyglass-ds light and in the image and video templates.
Props
The web component takes the same as attributes or properties (<spyglass-brand-light>); title is heading there.
<BrandLight>
| Prop | Type | Default |
|---|---|---|
variant | LightVariant band, field, corner, strip-left, strip-right, tile, close-up or curved-strip. | 'band' |
seed | number The same seed draws the same light; seeds below the brand's own windows reproduce them exactly. | 0 |
source | LightSource 'brand' cuts windows from the brand's own heat map; 'generated' builds a new one from the seed. | 'brand' |
width | number The frame the light is drawn for, in px (its proportions and its scale). | |
height | number | |
ground | boolean Paint the Black ground under it (on by default). | true |
cover | boolean Fill the box the classes give it (cropping the light) instead of keeping the frame's proportions. | false |
className | string |
Examples
The same example in React and as web components; both render identically.
import { BrandLight } from '@/react/components/visuals/BrandLight'
// A band of the light across a section, as the posts and ads use it.
export default function Band() {
return <BrandLight variant="band" seed={1} className="w-full rounded-container" />
}<!-- A band of the light across a section, as the posts and ads use it. -->
<spyglass-brand-light variant="band" seed="1" class="w-full rounded-container"></spyglass-brand-light>import { BrandLight } from '@/react/components/visuals/BrandLight'
// Every variant at seed 0, as the brand assets cut it.
const VARIANTS = ['band', 'field', 'corner', 'tile', 'close-up', 'curved-strip'] as const
export default function Variants() {
return (
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{VARIANTS.map((v) => (
<figure key={v} className="flex flex-col gap-2">
<BrandLight variant={v} cover className="aspect-[4/3] w-full rounded-container" />
<figcaption className="type-label text-fg-muted">{v}</figcaption>
</figure>
))}
<figure className="flex flex-col gap-2">
<div className="flex aspect-[4/3] w-full justify-between overflow-hidden rounded-container bg-surface">
<BrandLight variant="strip-left" className="h-full" />
<BrandLight variant="strip-right" className="h-full" />
</div>
<figcaption className="type-label text-fg-muted">strip-left, strip-right</figcaption>
</figure>
</div>
)
}<!-- Every variant at seed 0, as the brand assets cut it. -->
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="band" cover class="aspect-[4/3] w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">band</figcaption></figure>
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="field" cover class="aspect-[4/3] w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">field</figcaption></figure>
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="corner" cover class="aspect-[4/3] w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">corner</figcaption></figure>
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="tile" cover class="aspect-[4/3] w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">tile</figcaption></figure>
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="close-up" cover class="aspect-[4/3] w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">close-up</figcaption></figure>
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="curved-strip" cover class="aspect-[4/3] w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">curved-strip</figcaption></figure>
<figure class="flex flex-col gap-2">
<div class="flex aspect-[4/3] w-full justify-between overflow-hidden rounded-container bg-surface">
<spyglass-brand-light variant="strip-left" class="h-full"></spyglass-brand-light>
<spyglass-brand-light variant="strip-right" class="h-full"></spyglass-brand-light>
</div>
<figcaption class="type-label text-fg-muted">strip-left, strip-right</figcaption>
</figure>
</div>import { BrandLight } from '@/react/components/visuals/BrandLight'
// Heat maps built from a seed, the same way as the brand's: each seed is another light.
export default function Generated() {
return (
<div className="grid gap-4 sm:grid-cols-3">
{[3, 7, 11].map((seed) => (
<figure key={seed} className="flex flex-col gap-2">
<BrandLight variant="corner" source="generated" seed={seed} cover className="aspect-square w-full rounded-container" />
<figcaption className="type-label text-fg-muted">seed {seed}</figcaption>
</figure>
))}
</div>
)
}<!-- Heat maps built from a seed, the same way as the brand's: each seed is another light. -->
<div class="grid gap-4 sm:grid-cols-3">
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="corner" source="generated" seed="3" cover class="aspect-square w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">seed 3</figcaption></figure>
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="corner" source="generated" seed="7" cover class="aspect-square w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">seed 7</figcaption></figure>
<figure class="flex flex-col gap-2"><spyglass-brand-light variant="corner" source="generated" seed="11" cover class="aspect-square w-full rounded-container"></spyglass-brand-light><figcaption class="type-label text-fg-muted">seed 11</figcaption></figure>
</div>Source
import { useId, type CSSProperties } from 'react'
import { LIGHT_LAYERS, lightGeometry, type LightSource, type LightVariant } from '@/lib/light'
import { cn } from '@/react/lib/cn'
// The brand light, drawn from the seeded generator (lib/light.ts): the shape three times in Blue, Green and Red, each
// shifted sideways, blurred and blended plus-lighter on Black. It keeps the frame's proportions, or with `cover` fills
// the box its classes give it (`absolute inset-0` behind a section, `aspect-square w-full`), cropping the light. Put it at an edge or a
// corner, behind the content, never boxed in. It is decoration: hidden from assistive tech, and it does not move.
export interface BrandLightProps {
/** band, field, corner, strip-left, strip-right, tile, close-up or curved-strip. */
variant?: LightVariant
/** The same seed draws the same light; seeds below the brand's own windows reproduce them exactly. */
seed?: number
/** 'brand' cuts windows from the brand's own heat map; 'generated' builds a new one from the seed. */
source?: LightSource
/** The frame the light is drawn for, in px (its proportions and its scale). */
width?: number
height?: number
/** Paint the Black ground under it (on by default). */
ground?: boolean
/** Fill the box the classes give it (cropping the light) instead of keeping the frame's proportions. */
cover?: boolean
className?: string
}
/** Each variant's frame in the brand assets (px on the 1080 canvas). */
export const LIGHT_FRAMES: Record<LightVariant, [number, number]> = {
band: [1080, 240],
field: [1080, 612],
corner: [1080, 1080],
'strip-left': [160, 1080],
'strip-right': [160, 1080],
tile: [200, 200],
'close-up': [280, 208],
'curved-strip': [1920, 619],
}
export function BrandLight({ variant = 'band', seed = 0, source = 'brand', width, height, ground = true, cover = false, className }: BrandLightProps) {
const id = `sg-light${useId().replace(/[^\w-]/g, '')}`
const [w, h] = [width ?? LIGHT_FRAMES[variant][0], height ?? LIGHT_FRAMES[variant][1]]
const g = lightGeometry({ width: w, height: h, variant, seed, source })
const style: CSSProperties | undefined = cover ? undefined : { aspectRatio: `${w} / ${h}` }
return (
<div data-ds="brand-light" aria-hidden="true" style={style} className={cn('pointer-events-none overflow-hidden', ground && 'bg-surface', className)}>
<svg viewBox={`0 0 ${w} ${h}`} preserveAspectRatio="xMidYMid slice" className="block size-full isolate">
<defs>
<path id={`${id}-shape`} fillRule="evenodd" d={g.d} />
<filter id={`${id}-blur`} x="-10%" y="-10%" width="120%" height="120%" colorInterpolationFilters="sRGB">
<feGaussianBlur stdDeviation={Math.round(g.blur * 100) / 100} />
</filter>
</defs>
{LIGHT_LAYERS.map((l) => (
<use key={l.name} href={`#${id}-shape`} x={Math.round(g.offset * l.shift * 100) / 100} fill={l.color} opacity={l.opacity} filter={`url(#${id}-blur)`} style={{ mixBlendMode: 'plus-lighter' }} />
))}
</svg>
</div>
)
}
export default BrandLight// The brand light: one shape drawn three times, in Blue, Green and Red, each shifted sideways, blurred and blended
// plus-lighter on Black, so the colors separate at the edges and turn pale where all three overlap.
//
// In the brand assets every light is a window onto one heat map ("slide 1 light", MASTER_PATH) at some scale: a band
// across a post, a strip down its side, a tile beside a photo. This module does the same, deterministically:
//
// source 'brand' windows onto the brand's own heat map (seeds 0 to n-1 are the exact windows the brand assets
// use for that variant; higher seeds move and scale them a little)
// source 'generated' windows onto a new heat map built the same way (a dark body with the lit sea around it, a lit
// channel and ring along every edge, an island and loops), different for every seed
//
// Variants: band, field, corner (corner flow), strip-left, strip-right, tile, close-up and curved-strip. The output is
// geometry in the frame's pixels (one path, evenodd), which lightSvg turns into an SVG and drawLight paints on a canvas.
// No DOM, no randomness outside the seed, no dependencies: the same options give the same bytes everywhere.
import { MASTER_BOX, MASTER_PATH } from '@/lib/light-master'
export type LightVariant = 'band' | 'field' | 'corner' | 'strip-left' | 'strip-right' | 'tile' | 'close-up' | 'curved-strip'
export type LightSource = 'brand' | 'generated'
export const LIGHT_VARIANTS: LightVariant[] = ['band', 'field', 'corner', 'strip-left', 'strip-right', 'tile', 'close-up', 'curved-strip']
/** The three layers, as brand.json and tokens.css give them: each is shifted `shift` offsets to the right. */
export const LIGHT_LAYERS = [
{ name: 'Light B', color: '#1B1DFF', opacity: 0.782, shift: 0 },
{ name: 'Light G', color: '#00FF29', opacity: 0.782, shift: 1 },
{ name: 'Light R', color: '#DF0000', opacity: 0.85, shift: 2 },
] as const
/** Each layer's sideways offset and the blur, as shares of the heat map's width (Figma: 44.2 and 7.8 of 2913.3). */
export const LIGHT_OFFSET = 0.0152
export const LIGHT_BLUR = 0.00268
export interface LightOptions {
width: number
height: number
variant?: LightVariant
seed?: number
source?: LightSource
}
export interface LightGeometry {
width: number
height: number
variant: LightVariant
source: LightSource
seed: number
/** The lit shape in frame pixels, fill-rule evenodd. */
d: string
/** Each layer's shift step, in pixels. */
offset: number
/** The Gaussian blur's standard deviation, in pixels. */
blur: number
}
// ----- Seeded randomness -----
/** mulberry32: a small, fast, seeded generator. */
export function seeded(seed: number) {
let s = (seed | 0) ^ 0x2f6b1d
return () => {
s = (s + 0x6d2b79f5) | 0
let t = Math.imul(s ^ (s >>> 15), 1 | s)
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
}
}
// ----- Windows -----
// The windows the brand assets cut from the heat map, in Figma's numbers (page "8. Brand assets"): the heat map
// frame's x and y inside the window, the heat map vector's width (Light B's; Light R sits two offsets right), and the
// window's size. They are converted to the heat map's own units below (x and y as shares of its width).
type FigmaWindow = { fx: number; fy: number; vw: number; W: number; H: number; from: string }
const WINDOWS: Record<Exclude<LightVariant, 'curved-strip'>, FigmaWindow[]> = {
band: [
{ fx: -251.345, fy: -111.927, vw: 2860.331, W: 1080, H: 200.291, from: 'Post, Agents on Instagram and TikTok' },
{ fx: -1331, fy: -30, vw: 2913.3, W: 1080, H: 160, from: 'Post, Know what changed' },
{ fx: -239, fy: -127, vw: 2913.3, W: 1080, H: 240, from: 'Ad, The only creative search engine' },
{ fx: -1331, fy: 10, vw: 2913.3, W: 1080, H: 240, from: 'Ad, Testimonial' },
{ fx: -453, fy: -30, vw: 2913.3, W: 1080, H: 586, from: 'Post, Any brand or creator' },
],
field: [
{ fx: -929, fy: -39, vw: 2465.1, W: 1080, H: 612, from: 'Ad, Creator plan offer' },
{ fx: -2098.636, fy: -184.092, vw: 3300.39, W: 1080, H: 810, from: 'Ad, Search millions of creators (top)' },
],
corner: [
{ fx: -533, fy: -33, vw: 1725.57, W: 1080, H: 1080, from: 'Post, Offer' },
{ fx: -929, fy: -39, vw: 2465.1, W: 1080, H: 612, from: 'Ad, Creator plan offer' },
],
'strip-left': [{ fx: -134, fy: -160, vw: 2241, W: 160, H: 1080, from: 'Post, Every market (left)' }],
'strip-right': [{ fx: -2014, fy: -160, vw: 2241, W: 160, H: 1080, from: 'Post, Every market (right)' }],
tile: [
{ fx: -612.654, fy: -288.655, vw: 752.487, W: 111.927, H: 145.309, from: 'Post, Creative ring' },
{ fx: -644.072, fy: -365.237, vw: 858.099, W: 127.636, H: 127.636, from: 'Post, Creative ring' },
{ fx: -622.473, fy: -88.364, vw: 752.487, W: 111.927, H: 145.309, from: 'Post, Creative ring' },
{ fx: -691.2, fy: -353.455, vw: 858.099, W: 127.636, H: 127.636, from: 'Post, Creative ring' },
{ fx: -157, fy: -92, vw: 2689.2, W: 200, H: 200, from: 'Post, Any brand or creator' },
],
'close-up': [
{ fx: -20, fy: -15, vw: 940.68, W: 140, H: 104, from: 'Ad, The world’s largest creative search engine' },
{ fx: -1754, fy: -1180, vw: 2241, W: 200, H: 200, from: 'Post, Any brand or creator (light leak)' },
],
}
/** The heat map's height as a share of its width. */
const MASTER_H = MASTER_BOX.h / MASTER_BOX.w
/** The window for a variant and seed, in heat map units: left, top, width and height (shares of its width). */
export function lightWindow(variant: Exclude<LightVariant, 'curved-strip'>, seed: number, width: number, height: number) {
const list = WINDOWS[variant]
const n = list.length
const k = ((seed % n) + n) % n
const a = list[k]!
const w0 = a.W / a.vw
const cx0 = -a.fx / a.vw + w0 / 2
const cy0 = -a.fy / a.vw + a.H / a.vw / 2
// Seeds past the brand's own windows move and scale them a little, keeping the composition.
const rnd = seeded(seed * 7919 + 17)
const extra = Math.abs(seed) >= n ? 1 : 0
const w = w0 * (1 + extra * (rnd() - 0.5) * 0.16)
const h = (w * height) / width
let cx = cx0 + extra * (rnd() - 0.5) * w * 0.3
let cy = cy0 + extra * (rnd() - 0.5) * h * 0.3
// Inside the heat map where it fits: past its edge there is no light, only the edge of the frame.
// (A margin of four blurs, so the heat map's own edge never shows as a dimmed line.)
const m = LIGHT_BLUR * 4
if (w < 1 - 2 * m) cx = Math.min(Math.max(cx, w / 2 + m), 1 - w / 2 - m)
if (h < MASTER_H - 2 * m) cy = Math.min(Math.max(cy, h / 2 + m), MASTER_H - h / 2 - m)
return { x: cx - w / 2, y: cy - h / 2, w, h, from: a.from }
}
// ----- The brand heat map, in frame pixels -----
/** MASTER_PATH (M, L, H, V and Z, absolute) mapped by (x, y) -> (ax + b, ay + c). */
function mapMaster(scale: number, tx: number, ty: number, scaleY = scale) {
const out: string[] = []
let x = 0
let y = 0
const f = (n: number) => String(Math.round(n * 10) / 10)
for (const m of MASTER_PATH.matchAll(/([MLHVZ])([^MLHVZ]*)/g)) {
const nums = m[2]!.trim() ? m[2]!.trim().split(/[\s,]+/).map(Number) : []
const c = m[1]!
if (c === 'Z') {
out.push('Z')
continue
}
if (c === 'H') x = nums[0]!
else if (c === 'V') y = nums[0]!
else {
x = nums[0]!
y = nums[1]!
}
out.push(`${c === 'M' ? 'M' : 'L'}${f(x * scale + tx)} ${f(y * scaleY + ty)}`)
}
return out.join('')
}
// ----- A generated heat map -----
// Built the way the brand's is: a dark body (a smooth union of ellipses and a neck to the top edge) with the lit sea
// around it, a lit island inside it, loops near its edge, and the edges meandering. Distances are in heat map units
// (shares of its width), so the channel and ring along every edge keep one width, as the brand's do.
type Field = (u: number, v: number) => number
/** Smooth value noise in [-1, 1], seeded. */
function noise2(seed: number) {
const hash = (i: number, j: number) => {
let h = Math.imul(i, 374761393) + Math.imul(j, 668265263) + Math.imul(seed, 1442695041)
h = Math.imul(h ^ (h >>> 13), 1274126177)
return ((h ^ (h >>> 16)) >>> 0) / 4294967296
}
const s = (t: number) => t * t * (3 - 2 * t)
return (x: number, y: number) => {
const i = Math.floor(x)
const j = Math.floor(y)
const fx = s(x - i)
const fy = s(y - j)
const a = hash(i, j)
const b = hash(i + 1, j)
const c = hash(i, j + 1)
const d = hash(i + 1, j + 1)
return (a + (b - a) * fx + (c - a) * fy + (a - b - c + d) * fx * fy) * 2 - 1
}
}
/** Smooth maximum (a union of insides), polynomial, with blend width k. */
const smax = (a: number, b: number, k: number) => {
const h = Math.max(k - Math.abs(a - b), 0) / k
return Math.max(a, b) + (h * h * k) / 4
}
/** Inside distance of an ellipse (positive inside), approximate. */
const ellipse = (cx: number, cy: number, rx: number, ry: number, angle = 0): Field => {
const cs = Math.cos(angle)
const sn = Math.sin(angle)
return (u, v) => {
const dx = u - cx
const dy = v - cy
const x = (dx * cs + dy * sn) / rx
const y = (-dx * sn + dy * cs) / ry
return (1 - Math.hypot(x, y)) * Math.min(rx, ry)
}
}
/** Inside distance of a capsule from (ax, ay) to (bx, by) with radius r. */
const capsule = (ax: number, ay: number, bx: number, by: number, r: number): Field => (u, v) => {
const px = u - ax
const py = v - ay
const dx = bx - ax
const dy = by - ay
const t = Math.max(0, Math.min(1, (px * dx + py * dy) / (dx * dx + dy * dy)))
return r - Math.hypot(px - dx * t, py - dy * t)
}
/** The lit distance field of a generated heat map (positive in the lit sea), 1 unit wide and MASTER_H tall. */
export function generatedField(seed: number): Field {
const r = seeded(seed * 104729 + 11)
const j = (a: number) => (r() - 0.5) * 2 * a
const n = noise2(seed)
// The dark body, laid out as the brand's is: a main mass from about 0.08 to 0.92 across, under a sea along the top
// edge, a foot on the bottom edge, lobes to either side, and a neck up to the top edge right of center.
const neckU = 0.62 + j(0.06)
const parts: Field[] = [
ellipse(0.5 + j(0.03), 0.41 + j(0.02), 0.42 + j(0.02), 0.31 + j(0.02), j(0.12)),
ellipse(0.5 + j(0.05), 0.66, 0.46 + j(0.03), 0.12 + j(0.02)),
ellipse(0.26 + j(0.04), 0.22 + j(0.03), 0.16 + j(0.03), 0.1 + j(0.02), j(0.4)),
ellipse(0.74 + j(0.03), 0.3 + j(0.04), 0.12 + j(0.03), 0.18 + j(0.03), j(0.3)),
capsule(neckU, 0.24, neckU + j(0.04), -0.05, 0.03 + j(0.01)),
]
// Lit intrusions into the body: an arm from the left edge, the bottom right corner.
const armV = 0.44 + j(0.03)
const lit: Field[] = [
capsule(-0.05, armV, 0.22 + j(0.04), armV + 0.03 + j(0.02), 0.024 + j(0.008)),
ellipse(1.0, 0.64, 0.16 + j(0.03), 0.13 + j(0.03), j(0.3)),
]
// The island (a lit mass inside the body) and loops (rings with nothing inside), the smaller counterparts.
const island = ellipse(0.85 + j(0.03), 0.45 + j(0.03), 0.04 + j(0.01), 0.032 + j(0.008), j(1))
const loops = [
[0.27 + j(0.03), armV + 0.06 + j(0.015)],
[0.12 + j(0.1), 0.6 + j(0.01)],
]
// A small dark notch in the sea at the top left corner.
const notch = ellipse(0.045 + j(0.015), 0.035 + j(0.01), 0.03 + j(0.008), 0.022 + j(0.006), j(0.4))
return (u, v) => {
let body = -Infinity
for (const p of parts) body = smax(body, p(u, v), 0.06)
// The edges meander: low-frequency noise on the body's distance.
body += 0.03 * n(u * 4, v * 4) + 0.01 * n(u * 11 + 7, v * 11 + 3)
let d = -body
for (const p of lit) d = smax(d, p(u, v), 0.04)
d = Math.min(d, -notch(u, v))
d = smax(d, island(u, v), 0.01)
for (const [lu, lv] of loops) d = Math.max(d, -0.006 - Math.hypot(u - lu!, v - lv!))
return d
}
}
/** A curved strip: a lit ribbon below a wave across the frame (the deck cover's "Curved strip"). */
function curvedStripField(seed: number): Field {
const r = seeded(seed * 15485863 + 5)
const n = noise2(seed + 101)
const base = 0.52 + (r() - 0.5) * 0.06
const amp = 0.06 + r() * 0.03
const k = 2.4 + r() * 1.2
const ph = r() * Math.PI * 2
return (u, v) => {
const wave = base + amp * Math.sin(u * k * Math.PI + ph) + 0.025 * n(u * 3, 0.5)
const slope = amp * k * Math.PI * Math.cos(u * k * Math.PI + ph)
return (v - wave) / Math.sqrt(1 + slope * slope)
}
}
// ----- Contours -----
// The lit set is the sea (d > 0) and a ring along its edge (-(CHANNEL + RING) < d < -CHANNEL): with the three
// contours drawn as one evenodd path, the sea is lit, the channel dark, the ring lit and the rest dark.
const CHANNEL = 0.0085
const RING = 0.0105
type Pt = [number, number]
/** Closed contours of a grid at a level (marching squares), as point loops in grid coordinates. */
function contours(grid: Float64Array, cols: number, rows: number, level: number): Pt[][] {
const at = (i: number, j: number) => grid[j * cols + i]! - level
// Edges: horizontal edge (i, j)-(i+1, j) is id 2*(j*cols+i), vertical edge (i, j)-(i, j+1) is id 2*(j*cols+i)+1.
const point = (e: number): Pt => {
const k = e >> 1
const i = k % cols
const j = (k - i) / cols
if (e & 1) {
const a = at(i, j)
const b = at(i, j + 1)
return [i, j + a / (a - b)]
}
const a = at(i, j)
const b = at(i + 1, j)
return [i + a / (a - b), j]
}
const next = new Map<number, number>()
const H = (i: number, j: number) => 2 * (j * cols + i)
const V = (i: number, j: number) => 2 * (j * cols + i) + 1
for (let j = 0; j < rows - 1; j++) {
for (let i = 0; i < cols - 1; i++) {
const a = at(i, j) > 0 ? 1 : 0
const b = at(i + 1, j) > 0 ? 1 : 0
const c = at(i + 1, j + 1) > 0 ? 1 : 0
const d = at(i, j + 1) > 0 ? 1 : 0
const code = a * 8 + b * 4 + c * 2 + d
const top = H(i, j)
const right = V(i + 1, j)
const bottom = H(i, j + 1)
const left = V(i, j)
// Segments run with the inside (above the level) on their right, so loops come out consistently wound.
const seg = (from: number, to: number) => next.set(from, to)
switch (code) {
case 1: seg(bottom, left); break
case 2: seg(right, bottom); break
case 3: seg(right, left); break
case 4: seg(top, right); break
case 5: {
const center = (at(i, j) + at(i + 1, j) + at(i + 1, j + 1) + at(i, j + 1)) / 4
if (center > 0) { seg(top, left); seg(bottom, right) } else { seg(top, right); seg(bottom, left) }
break
}
case 6: seg(top, bottom); break
case 7: seg(top, left); break
case 8: seg(left, top); break
case 9: seg(bottom, top); break
case 10: {
const center = (at(i, j) + at(i + 1, j) + at(i + 1, j + 1) + at(i, j + 1)) / 4
if (center > 0) { seg(left, bottom); seg(right, top) } else { seg(left, top); seg(right, bottom) }
break
}
case 11: seg(right, top); break
case 12: seg(left, right); break
case 13: seg(bottom, right); break
case 14: seg(left, bottom); break
}
}
}
const loops: Pt[][] = []
const seen = new Set<number>()
for (const start of next.keys()) {
if (seen.has(start)) continue
const loop: Pt[] = []
let e: number | undefined = start
while (e !== undefined && !seen.has(e)) {
seen.add(e)
loop.push(point(e))
e = next.get(e)
}
if (loop.length > 2) loops.push(loop)
}
return loops
}
/** A closed loop as a smooth path: quadratic curves through the midpoints, with the points as controls. */
function smoothPath(loop: Pt[], map: (p: Pt) => Pt) {
// Every other point is enough for curves through the midpoints (the blur hides less), and halves the path.
const pts = (loop.length > 12 ? loop.filter((_, i) => i % 2 === 0) : loop).map(map)
const f = (n: number) => String(Math.round(n * 10) / 10)
const mid = (a: Pt, b: Pt): Pt => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2]
const n = pts.length
const start = mid(pts[n - 1]!, pts[0]!)
let d = `M${f(start[0])} ${f(start[1])}`
for (let i = 0; i < n; i++) {
const p = pts[i]!
const m = mid(p, pts[(i + 1) % n]!)
d += `Q${f(p[0])} ${f(p[1])} ${f(m[0])} ${f(m[1])}`
}
return `${d}Z`
}
/** A field's lit shape in a window, as an evenodd path in frame pixels. */
function fieldPath(field: Field, win: { x: number; y: number; w: number; h: number }, width: number, height: number) {
// Cells about 1/140 of the window's longer side, and a margin past the frame wide enough for the blur and the shifted layers.
const cell = Math.max(win.w, win.h) / 140
const margin = LIGHT_OFFSET * 2 + LIGHT_BLUR * 4 + cell * 2
const pad = Math.ceil(margin / cell)
const cols = Math.ceil(win.w / cell) + 2 * pad + 1
const rows = Math.ceil(win.h / cell) + 2 * pad + 1
const grid = new Float64Array(cols * rows)
for (let j = 0; j < rows; j++) {
for (let i = 0; i < cols; i++) {
// The outermost cells close every contour outside the frame.
const edge = i === 0 || j === 0 || i === cols - 1 || j === rows - 1
grid[j * cols + i] = edge ? -1 : field(win.x + (i - pad) * cell, win.y + (j - pad) * cell)
}
}
const sx = width / win.w
const sy = height / win.h
const map = (p: Pt): Pt => [(p[0] - pad) * cell * sx, (p[1] - pad) * cell * sy]
const paths: string[] = []
for (const level of [0, -CHANNEL, -(CHANNEL + RING)]) for (const loop of contours(grid, cols, rows, level)) paths.push(smoothPath(loop, map))
return paths.join('')
}
// ----- Geometry -----
/** The light for a frame: its lit shape in frame pixels, the layers' offset and the blur. */
export function lightGeometry(options: LightOptions): LightGeometry {
const { width, height } = options
const variant = options.variant ?? 'band'
const seed = Math.trunc(options.seed ?? 0)
const source = options.source ?? 'brand'
if (!(width > 0 && height > 0)) throw new Error('lightGeometry needs a width and a height above 0')
if (!LIGHT_VARIANTS.includes(variant)) throw new Error(`Unknown light variant \`${variant}\`. Variants: ${LIGHT_VARIANTS.join(', ')}.`)
if (variant === 'curved-strip') {
// The deck's curved strip spans 2240 units across a 1920 frame: the heat map is about 1.17 frames wide.
const w = 1 / 1.17
const win = { x: (1 - w) / 2, y: 0.52 - (w * height) / width / 2, w, h: (w * height) / width }
const px = width / win.w
return { width, height, variant, source, seed, d: fieldPath(curvedStripField(seed), win, width, height), offset: LIGHT_OFFSET * px, blur: LIGHT_BLUR * px }
}
const win = lightWindow(variant, seed, width, height)
const px = width / win.w
const d = source === 'brand'
? mapMaster(px / MASTER_BOX.w, -MASTER_BOX.x * (px / MASTER_BOX.w) - win.x * px, -MASTER_BOX.y * (px / MASTER_BOX.w) - win.y * px)
: fieldPath(generatedField(seed), win, width, height)
return { width, height, variant, source, seed, d, offset: LIGHT_OFFSET * px, blur: LIGHT_BLUR * px }
}
const num = (n: number) => String(Math.round(n * 100) / 100)
export interface LightSvgOptions extends LightOptions {
/** Paint the Black ground under the light (default true). */
ground?: boolean
/** 'css' blends the layers with mix-blend-mode: plus-lighter (browsers); 'filter' adds them in an SVG filter,
* which renders the same on Black and also in rasterizers without CSS blend modes (resvg). Default 'css'. */
blend?: 'css' | 'filter'
/** A prefix for the ids inside the SVG, so several can sit on one page. */
id?: string
}
/** The light as a standalone SVG document. */
export function lightSvg(options: LightSvgOptions): string {
return lightGeometrySvg(lightGeometry(options), options)
}
/** A light placed as the brand assets place it: the heat map's Light B layer drawn at `b` (x, y, width and height in
* the frame's pixels, so a window can stretch it as the deck and banner backgrounds do), each layer `shift` pixels
* right of the last. Seed 0 with source 'brand' is the brand's own heat map; source 'generated' fills the same window
* from a heat map generated from the seed. */
export interface LightPlacement {
width: number
height: number
b: { x: number; y: number; w: number; h: number }
shift: number
source?: LightSource
seed?: number
}
export function placedLightGeometry(p: LightPlacement): LightGeometry {
const { width, height, b, shift } = p
if (!(width > 0 && height > 0 && b.w > 0 && b.h > 0)) throw new Error('placedLightGeometry needs a frame and a layer above 0')
const source = p.source ?? 'brand'
const seed = Math.trunc(p.seed ?? 0)
const sx = b.w / MASTER_BOX.w
const sy = b.h / MASTER_BOX.h
// The blur keeps its ratio to the shift (7.8 to 44.2 in the heat map's own units), so a stretched light blurs as much as it separates.
const blur = shift * (LIGHT_BLUR / LIGHT_OFFSET)
if (source === 'brand') return { width, height, variant: 'field', source, seed, d: mapMaster(sx, b.x - MASTER_BOX.x * sx, b.y - MASTER_BOX.y * sy, sy), offset: shift, blur }
const win = { x: -b.x / b.w, y: (-b.y / b.h) * MASTER_H, w: width / b.w, h: (height / b.h) * MASTER_H }
return { width, height, variant: 'field', source, seed, d: fieldPath(generatedField(seed), win, width, height), offset: shift, blur }
}
/** The SVG for a geometry (lightSvg and placed lights share it). */
export function lightGeometrySvg(g: LightGeometry, options: Pick<LightSvgOptions, 'ground' | 'blend' | 'id'> = {}): string {
const id = options.id ?? `sg-light-${g.variant}-${g.seed}`
const ground = options.ground !== false ? `<rect width="${num(g.width)}" height="${num(g.height)}" fill="#000000"/>` : ''
const head = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${num(g.width)}" height="${num(g.height)}" viewBox="0 0 ${num(g.width)} ${num(g.height)}" style="isolation:isolate">`
const shape = `<path id="${id}-shape" fill-rule="evenodd" d="${g.d}"/>`
if (options.blend === 'filter') {
// One filter adds the three tinted, shifted, blurred copies of the shape's alpha: plus-lighter, in SVG.
const tint = (c: string, o: number) => {
const [r, gr, b] = [1, 3, 5].map((k) => parseInt(c.slice(k, k + 2), 16) / 255)
// The color itself (unpremultiplied) and the opacity on the alpha: the filter premultiplies once.
return `0 0 0 0 ${num(r!)} 0 0 0 0 ${num(gr!)} 0 0 0 0 ${num(b!)} 0 0 0 ${o} 0`
}
// The region reaches past the frame, so the shifted layers and the blur do not stop at its edge.
const pad = g.offset * 2 + g.blur * 4
const steps = LIGHT_LAYERS.map((l, i) => `<feOffset in="blur" dx="${num(g.offset * l.shift)}" dy="0" result="o${i}"/><feColorMatrix in="o${i}" type="matrix" values="${tint(l.color, l.opacity)}" result="c${i}"/>`).join('')
const add = '<feComposite in="c0" in2="c1" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="a01"/><feComposite in="a01" in2="c2" operator="arithmetic" k1="0" k2="1" k3="1" k4="0"/>'
return `${head}<defs><filter id="${id}-add" x="${num(-pad)}" y="${num(-pad)}" width="${num(g.width + 2 * pad)}" height="${num(g.height + 2 * pad)}" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feGaussianBlur in="SourceAlpha" stdDeviation="${num(g.blur)}" result="blur"/>${steps}${add}</filter></defs>${ground}<g filter="url(#${id}-add)"><path fill="#FFFFFF" fill-rule="evenodd" d="${g.d}"/></g></svg>`
}
const uses = LIGHT_LAYERS.map((l) => `<use xlink:href="#${id}-shape" href="#${id}-shape" x="${num(g.offset * l.shift)}" fill="${l.color}" opacity="${l.opacity}" filter="url(#${id}-blur)" style="mix-blend-mode:plus-lighter"/>`).join('')
return `${head}<defs>${shape}<filter id="${id}-blur" x="-10%" y="-10%" width="120%" height="120%" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="${num(g.blur)}"/></filter></defs>${ground}<g style="isolation:isolate">${uses}</g></svg>`
}
/** The parts of a 2D canvas context drawLight uses (a browser canvas or a node-canvas one). */
export interface LightCanvas {
save(): void
restore(): void
translate(x: number, y: number): void
fill(path: unknown, rule?: 'evenodd' | 'nonzero'): void
fillStyle: unknown
globalAlpha: number
globalCompositeOperation: string
filter: string
}
/** Paints the light onto a canvas that is already Black (or transparent over Black). Path2D comes from the caller's
* environment (globalThis.Path2D in a browser). */
export function drawLight(ctx: LightCanvas, g: LightGeometry, Path: new (d: string) => unknown = (globalThis as unknown as { Path2D: new (d: string) => unknown }).Path2D) {
const path = new Path(g.d)
ctx.save()
ctx.globalCompositeOperation = 'lighter'
ctx.filter = `blur(${g.blur}px)`
for (const l of LIGHT_LAYERS) {
ctx.save()
ctx.translate(g.offset * l.shift, 0)
ctx.globalAlpha = l.opacity
ctx.fillStyle = l.color
ctx.fill(path, 'evenodd')
ctx.restore()
}
ctx.restore()
}// The brand's own light: the heat map Figma names "slide 1 light", as its Light R layer exports it
// (brand/light/master-r.svg, the fill path; the other two layers are the same path). Every light in the brand assets
// is a window onto this one shape at some scale. Its bounding box is (16.25, 16.25) to (2929.55, 1837.55): 2913.3 by
// 1821.3 units. Fill rule: evenodd.
export const MASTER_PATH = 'M840.45 1597.05L804.05 1594.45L766.35 1586.65L733.85 1574.95L707.85 1560.65L689.65 1545.05L672.75 1522.95L612.95 1409.85L570.05 1385.15L520.65 1369.55L466.05 1363.05L401.05 1365.65L193.05 1400.75L66.95 1415.05L16.25 1424.15V16.25H1823.25L1815.45 47.45L1792.05 85.15L1727.05 130.65L1682.85 156.65L1534.65 221.65L1482.65 250.25L1431.95 287.95L1321.45 385.45L1287.65 408.85L1255.15 425.75L1227.85 434.85L1201.85 437.45L1173.25 436.15L1144.65 429.65L1090.05 408.85L988.65 351.65L936.65 334.75L879.45 330.85L818.35 338.65L771.55 354.25L723.45 375.05L609.05 437.45L550.55 477.75L511.55 499.85L317.85 588.25L264.55 628.55L243.75 650.65L225.55 676.65L208.65 707.85L198.25 742.95L191.75 783.25L190.45 822.25L195.65 858.65L222.95 991.25L232.05 1131.65L242.45 1166.75L258.05 1196.65L276.25 1218.75L297.05 1238.25L323.05 1253.85L350.35 1265.55L518.05 1309.75L676.65 1334.45L781.95 1357.85L827.45 1373.45L915.85 1409.85L965.25 1435.85L982.15 1454.05L984.75 1477.45L978.25 1503.45L957.45 1537.25L932.75 1564.55L905.45 1582.75L874.25 1593.15L840.45 1597.05ZM2925.65 1837.55L2417.35 1836.25L2419.95 1807.65L2429.05 1773.85L2452.45 1743.95L2491.45 1703.65L2548.65 1655.55L2596.75 1619.15L2647.45 1586.65L2698.15 1512.55L2754.05 1451.45L2799.55 1411.15L2900.95 1335.75L2915.25 1318.85L2924.35 1303.25L2928.25 1287.65L2926.95 1272.05L2916.55 1249.95L2900.95 1227.85L2880.15 1209.65L2859.35 1197.95L2839.85 1192.75H2811.25L2787.85 1197.95L2767.05 1207.05L2747.55 1222.65L2731.95 1243.45L2666.95 1385.15L2639.65 1430.65L2616.25 1461.85L2588.95 1486.55L2559.05 1503.45L2501.85 1522.95L2475.85 1525.55L2434.25 1519.05L2397.85 1495.65L2375.75 1472.25L2326.35 1403.35L2228.85 1311.05L2198.95 1278.55L2179.45 1243.45L2176.85 1227.85L2180.75 1210.95L2189.85 1196.65L2204.15 1183.65L2249.65 1161.55L2319.85 1144.65L2418.65 1134.25L2509.65 1132.95L2595.45 1142.05L2616.25 1136.85L2631.85 1123.85L2639.65 1103.05L2646.15 954.85V850.85L2639.65 744.25L2626.65 718.25L2614.95 709.15L2600.65 702.65L2582.45 701.35L2496.65 714.35L2444.65 711.75L2418.65 705.25L2391.35 694.85L2367.95 679.25L2347.15 661.05L2322.45 627.25L2308.15 585.65L2301.65 536.25L2305.55 458.25L2301.65 429.65L2287.35 369.85L2262.65 319.15L2226.25 271.05L2179.45 224.25L2085.85 148.85L1990.95 79.95L1966.25 42.25L1959.75 16.25H2928.25L2929.55 1833.65L2925.65 1837.55ZM892.45 1836.25L830.05 1833.65L835.25 1819.35L844.35 1806.35L858.65 1797.25L871.65 1794.65L884.65 1799.85L892.45 1810.25L898.95 1833.65L892.45 1836.25ZM16.25 1326.65V16.25L1751.75 17.55L1747.85 46.15L1733.55 77.35L1702.35 104.65L1643.85 141.05L1529.45 191.75L1482.65 216.45L1438.45 247.65L1331.85 336.05L1298.05 358.15L1266.85 372.45L1212.25 385.45L1160.25 380.25L1117.35 364.65L1019.85 313.95L957.45 297.05L892.45 293.15L823.55 302.25L759.85 321.75L692.25 351.65L567.45 416.65L518.05 453.05L467.35 484.25L324.35 553.15L271.05 586.95L229.45 624.65L194.35 671.45L170.95 724.75L156.65 780.65L155.35 843.05L173.55 947.05L178.75 996.45L177.45 1048.45L165.75 1147.25L173.55 1235.65L172.25 1255.15L167.05 1264.25L156.65 1269.45L109.85 1277.25L76.05 1288.95L16.25 1326.65ZM2925.65 1142.05L2894.45 1126.45L2865.85 1118.65L2754.05 1105.65L2735.85 1097.85L2720.25 1083.55L2708.55 1061.45L2702.05 1027.65L2687.75 744.25L2682.55 723.45L2673.45 703.95L2661.75 690.95L2647.45 679.25L2611.05 667.55H2587.65L2501.85 681.85L2449.85 677.95L2409.55 662.35L2378.35 637.65L2356.25 603.85L2341.95 567.45L2335.45 518.05V427.05L2319.85 363.35L2296.45 307.45L2266.55 261.95L2226.25 216.45L2174.25 170.95L2066.35 82.55L2048.15 47.45L2042.95 16.25H2928.25L2929.55 973.05L2925.65 1142.05ZM2504.45 1478.75H2483.65L2462.85 1476.15L2443.35 1468.35L2423.85 1456.65L2397.85 1433.25L2288.65 1316.25L2261.35 1279.85L2250.95 1252.55L2252.25 1229.15L2269.15 1207.05L2299.05 1190.15L2344.55 1175.85L2406.95 1165.45L2475.85 1160.25L2520.05 1161.55L2559.05 1166.75L2631.85 1186.25L2655.25 1200.55L2665.65 1225.25V1266.85L2653.95 1314.95L2634.45 1363.05L2605.85 1409.85L2574.65 1443.65L2540.85 1467.05L2504.45 1478.75ZM830.05 1539.85L801.45 1537.25L775.45 1529.45L755.95 1517.75L739.05 1503.45L723.45 1477.45L715.65 1451.45V1430.65L723.45 1415.05L735.15 1407.25L750.75 1404.65L796.25 1411.15L858.65 1435.85L884.65 1451.45L901.55 1467.05L908.05 1478.75L909.35 1490.45L906.75 1503.45L898.95 1513.85L885.95 1525.55L869.05 1533.35L830.05 1539.85ZM2925.65 1837.55L2517.45 1836.25L2452.45 1833.65L2457.65 1805.05L2468.05 1775.15L2496.65 1745.25L2538.25 1711.45L2595.45 1673.75L2648.75 1642.55L2699.45 1617.85L2769.65 1535.95L2815.15 1490.45L2865.85 1451.45L2926.95 1416.35L2929.55 1833.65L2925.65 1837.55ZM16.25 1092.65V16.25H135.85L148.85 83.85L108.55 113.75L64.35 135.85L43.55 190.45L39.65 208.65L42.25 228.15L57.85 245.05L83.85 255.45L122.85 259.35L193.05 251.55L241.15 239.85L248.95 234.65L263.25 195.65L273.65 154.05L277.55 115.05L276.25 83.85L302.25 50.05L315.25 16.25H1708.85L1701.05 52.65L1689.35 77.35L1680.25 86.45L1624.35 120.25L1521.65 165.75L1477.45 189.15L1435.85 219.05L1338.35 302.25L1305.85 323.05L1274.65 338.65L1226.55 349.05L1178.45 346.45L1140.75 333.45L1041.95 287.95L969.15 271.05L892.45 268.45L811.85 278.85L763.75 291.85L711.75 310.05L527.15 393.25L477.75 432.25L430.95 463.45L287.95 544.05L238.55 580.45L196.95 623.35L165.75 672.75L139.75 728.65L126.75 772.85L120.25 811.85V852.15L129.35 954.85L125.45 989.95L116.35 1015.95L98.15 1039.35L16.25 1092.65ZM2928.25 1082.25L2881.45 1062.75L2804.75 1044.55L2782.65 1030.25L2765.75 1009.45L2751.45 967.85L2742.35 908.05L2734.55 827.45L2729.35 715.65L2718.95 681.85L2699.45 655.85L2669.55 640.25L2631.85 635.05L2595.45 637.65L2517.45 653.25H2468.05L2426.45 638.95L2408.25 624.65L2393.95 609.05L2377.05 581.75L2366.65 547.95L2360.15 505.05L2358.85 421.85L2340.65 349.05L2317.25 290.55L2288.65 243.75L2250.95 199.55L2205.45 156.65L2117.05 83.85L2101.45 48.75L2094.95 16.25H2928.25V1082.25ZM2509.65 1447.55L2474.55 1446.25L2439.45 1430.65L2408.25 1403.35L2347.15 1337.05L2321.15 1299.35L2308.15 1269.45L2309.45 1243.45L2326.35 1222.65L2354.95 1207.05L2392.65 1195.35L2445.95 1186.25L2496.65 1183.65L2533.05 1186.25L2564.25 1194.05L2599.35 1210.95L2617.55 1226.55L2629.25 1248.65L2633.15 1279.85L2626.65 1316.25L2612.35 1352.65L2590.25 1389.05L2564.25 1417.65L2538.25 1435.85L2509.65 1447.55ZM2925.65 1836.25L2482.35 1833.65L2486.25 1810.25L2496.65 1784.25L2507.05 1768.65L2521.35 1756.95L2573.35 1720.55L2637.05 1686.75L2690.35 1664.65L2756.65 1645.15L2850.25 1545.05L2886.65 1513.85L2926.95 1483.95L2928.25 1833.65L2925.65 1836.25Z'
export const MASTER_BOX = { x: 16.25, y: 16.25, w: 2913.3, h: 1821.3 }// Joins class names, skipping falsy ones: cn('a', on && 'b', ['c', undefined]). It does not merge conflicting
// utilities (no tailwind-merge), as Vue's class binding does not: the library's classes are written not to compete,
// and a className from the caller is appended after them, as Vue appends a fallthrough class.
export type ClassValue = string | false | null | undefined | 0 | ClassValue[]
export function cn(...values: ClassValue[]): string {
const out: string[] = []
for (const v of values) {
if (!v) continue
if (Array.isArray(v)) {
const s = cn(...v)
if (s) out.push(s)
}
else out.push(v)
}
return out.join(' ')
}import { html, svg } from 'lit'
import { DsElement, define, uid } from '@/elements/lib/element'
import { LIGHT_LAYERS, lightGeometry, type LightSource, type LightVariant } from '@/lib/light'
import styles from 'virtual:tw'
// BrandLight.tsx as <spyglass-brand-light>: the brand light from the seeded generator (lib/light.ts), the shape three
// times in Blue, Green and Red, shifted, blurred and blended plus-lighter on Black. The element is the box (size it
// with classes as the React root); it keeps the frame's proportions unless `cover`. Decoration: aria-hidden.
/** Each variant's frame in the brand assets (px on the 1080 canvas). */
const FRAMES: Record<LightVariant, [number, number]> = {
band: [1080, 240],
field: [1080, 612],
corner: [1080, 1080],
'strip-left': [160, 1080],
'strip-right': [160, 1080],
tile: [200, 200],
'close-up': [280, 208],
'curved-strip': [1920, 619],
}
const r2 = (n: number) => Math.round(n * 100) / 100
/**
* @summary The brand light, generated from a seed.
*/
export class BrandLight extends DsElement {
static styles = [DsElement.styles, styles]
static properties = {
variant: {},
seed: { type: Number },
source: {},
width: { type: Number },
height: { type: Number },
ground: { type: Boolean, converter: { fromAttribute: (v: string | null) => v !== 'false' } },
cover: { type: Boolean },
}
/** band, field, corner, strip-left, strip-right, tile, close-up or curved-strip. */
variant: LightVariant = 'band'
/** The same seed draws the same light. */
seed = 0
/** 'brand' (windows onto the brand's heat map) or 'generated'. */
source: LightSource = 'brand'
/** The frame it is drawn for, in px. */
width?: number
height?: number
/** Paint the Black ground under it (ground="false" to leave it out). */
ground = true
/** Fill the box its classes give it instead of keeping the frame's proportions. */
cover = false
private lightId = uid('sg-light')
connectedCallback() {
super.connectedCallback()
this.setAttribute('aria-hidden', 'true')
}
render() {
const frame = FRAMES[this.variant] ?? FRAMES.band
const w = this.width ?? frame[0]
const h = this.height ?? frame[1]
const g = lightGeometry({ width: w, height: h, variant: this.variant, seed: this.seed, source: this.source })
this.style.aspectRatio = this.cover ? '' : `${w} / ${h}`
this.toggleAttribute('data-ground', this.ground)
return html`<svg viewBox="0 0 ${w} ${h}" preserveAspectRatio="xMidYMid slice" class="block size-full isolate"><defs><path id="${this.lightId}-shape" fill-rule="evenodd" d=${g.d}></path><filter id="${this.lightId}-blur" x="-10%" y="-10%" width="120%" height="120%" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation=${r2(g.blur)}></feGaussianBlur></filter></defs>${LIGHT_LAYERS.map((l) => svg`<use href="#${this.lightId}-shape" x=${r2(g.offset * l.shift)} fill=${l.color} opacity=${l.opacity} filter="url(#${this.lightId}-blur)" style="mix-blend-mode:plus-lighter"></use>`)}</svg>`
}
}
define('brand-light', BrandLight)/* The element is the box, as BrandLight.tsx's root: the page's classes size and place it. */
:host {
display: block;
overflow: hidden;
pointer-events: none;
}
:host([data-ground]) {
background-color: var(--ds-color-surface);
}Reference: Brand guidelines page 33 (Brand pattern); Figma page 8: Heat map (slide 1 light), Light R, G and B layers (opacity 0.85, 0.782, 0.782; offset 1.52% of the heat map's width; blur 7.8 of 2913), and every Light band, field, strip, tile and close-up window.