> ## Documentation Index
> Fetch the complete documentation index at: https://glassen.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Glassen API reference

> Reference the Glassen entry points, lens settings, mount lifetimes, frame values and optional DOM and ASCII adapters without pulling in unused engines.

Glassen exports factories and optional adapters. Each mount owns its rendering resources; caller-provided sources and shared shapes retain their own lifetime.

## Entry points

| Import | Exports |
| - | - |
| `glassen` | `createGlass`, `createGlassSurface`, `glassDefaults`, `initGlass`, `createPathShape`, `createMaskShape` |
| `glassen/react` | `Glass`, `GlassSurface`, `GlassContent` |
| `glassen/dom` | `createDOMSource` |
| `glassen/crt` | `createCRTSource` |
| `glassen/nested` | `createNestedOrbScene`, `initNestedGlass` |
| `glassen/nested/react` | `NestedOrbs` |
| `glassen/ascii` | `createAsciiSource`, `asciiPresets` |
| `glassen/glsl` | Default shader body, named `PREPARE` helper |
| `glassen/style.css` | DOM layout styles |
| `glassen/wasm/*.wasm` | Compiled lens and nested scene modules |

## Lens options

Pass these to `createGlass(canvas, options)`, `surface.add(element, options)` or `mount.update(options)`.

| Option | Meaning |
| - | - |
| `appearance` | `'light'`, `'dark'` or `'system'`; omitted follows the system |
| `shape` | Shared shape object, or `null` for the default orb |
| `source` | `GlassSource`; omitted on a surface samples its scene content when present |
| `refraction` | Bend strength; default 190, clamped to 0–350 |
| `dispersion` | Chromatic separation; default 4, clamped to 0–12 |
| `shadow` | Shadow multiplier; default 1, clamped to 0–2 |
| `highlights` | Highlight multiplier; default 1, clamped to 0–3 |
| `interactive` | Set `false` to disable pointer and keyboard interaction |
| `zIndex` | Back-to-front paint order; default 0, stable for ties |
| `onMove(delta, element)` | Incremental damped CSS-pixel movement; host applies positioning |

`await glassDefaults(dark = false)` returns the appearance's `refraction`, `dispersion`, `shadow`, `highlights` and CSS `background` string from Rust. Do not duplicate those defaults in a host adapter.

`createGlass` resolves to a mount with `update` and `destroy`. `createGlassSurface` resolves to a surface with `add`, `addContent`, `stats` and `destroy`. `addContent` accepts `source` and `appearance`. Updates merge into existing options. Destroy methods are idempotent.

## Source frame

`time` is seconds on the surface clock. `size`, `width` and `height` describe CSS dimensions; `pixels`, `pixelWidth` and `pixelHeight` describe physical dimensions. `look` is a normalized pointer point, `reduced` reflects reduced-motion preference, and `owner` identifies the consuming surface resource.

## DOM capture

```js theme={null}
import { createDOMSource } from 'glassen/dom'
const source = createDOMSource(element, { live: false, onError: console.error })
// source.invalidate() after changes not observed by the DOM adapter.
// source.destroy() after removing all consumers.
```

DOM capture observes mutations, resize, image loads and fonts. Canvas pixel writes and CSS-only animation do not produce DOM mutations. Prefer a canvas/GPU source for animation. Captured DOM should still have accessible original content.

## ASCII sources

```js theme={null}
import { createAsciiSource } from 'glassen/ascii'
const source = createAsciiSource({ preset: 'moire', opacity: 0.32 })
source.update({ zoom: 0.9 })
```

Options are `dark`, `scale`, `speed`, `opacity`, `preset`, `colored` and `zoom`. Presets are `wobbly`, `moire`, `mobius`, `trefoil`, `sphere`, `poem`, `sigils` and `shards`. The surface owns the GPU renderer returned by the source. Keep the bundled ASCII credits when copying these adaptations.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.