Matrix
sv11-twango/matrixFreeComponent
An ambient dot-matrix canvas animation with configurable presets.
Live preview
live · rendered by the registry
Rendered by sv11-twango on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add http://sv11.ui.twango.dev/r/matrix.jsonSource
1<script lang="ts" module>2 import type { HTMLAttributes } from "svelte/elements";3 import type { Frame } from "./presets.js";45 export type MatrixMode = "default" | "vu";67 export type MatrixProps = HTMLAttributes<HTMLDivElement> & {8 /** Number of rows in the matrix grid. */9 rows: number;10 /** Number of columns in the matrix grid. */11 cols: number;12 /**13 * Static pattern to display. A 2D array of brightness values in14 * `[0, 1]`. When set, animation is disabled and `frames` is ignored.15 */16 pattern?: Frame;17 /**18 * Ordered frames to loop through for animation. Ignored when19 * `pattern` is provided.20 */21 frames?: Frame[];22 /**23 * Playback rate in frames per second when animating `frames`.24 * @default 1225 */26 fps?: number;27 /**28 * Start animating automatically on mount. Ignored when a static29 * `pattern` is provided.30 * @default true31 */32 autoplay?: boolean;33 /**34 * Loop the frame sequence. When `false`, animation halts on the last35 * frame.36 * @default true37 */38 loop?: boolean;39 /**40 * Cell diameter in pixels.41 * @default 1042 */43 size?: number;44 /**45 * Gap between cells in pixels.46 * @default 247 */48 gap?: number;49 /**50 * CSS colors for active and inactive cells. Defaults map `on` to the51 * current text color and `off` to the muted foreground token.52 * @default { on: "currentColor", off: "var(--muted-foreground)" }53 */54 palette?: { on: string; off: string };55 /**56 * Global brightness multiplier applied to every cell, clamped to57 * `[0, 1]`.58 * @default 159 */60 brightness?: number;61 /**62 * ARIA label for the container. Falls back to `"matrix display"` when63 * omitted.64 */65 ariaLabel?: string;66 /** Invoked whenever the active frame index changes during animation. */67 onFrame?: (index: number) => void;68 /**69 * Rendering mode. `"vu"` reads `levels` each render to draw a70 * bottom-anchored meter instead of `frames` or `pattern`.71 * @default "default"72 */73 mode?: MatrixMode;74 /**75 * Per-column level values in `[0, 1]` used when `mode="vu"`. Ignored76 * in other modes.77 */78 levels?: number[];79 /** Bound reference to the root container element. */80 ref?: HTMLDivElement | null;81 };82</script>8384<script lang="ts">85 import { cn } from "$UTILS$.js";86 import { clamp, ensureFrameSize, vu } from "./presets.js";8788 let {89 rows,90 cols,91 pattern,92 frames,93 fps = 12,94 autoplay = true,95 loop = true,96 size = 10,97 gap = 2,98// … truncated
More from sv11-twango
All 29 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Audio Playeraudio-player | sv11-twango | Components | Free | 2 deps | |
| Bar Visualizerbar-visualizer | sv11-twango | Components | Free | no deps | |
| Conversationconversation | sv11-twango | Components | Free | 2 deps | |
| Conversation Barconversation-bar | sv11-twango | Components | Free | 1 dep | |
| Live Waveformlive-waveform | sv11-twango | Components | Free | no deps | |
| Messagemessage | sv11-twango | Components | Free | 2 deps | |
| Mic Selectormic-selector | sv11-twango | Components | Free | 1 dep | |
| Orborb | sv11-twango | Components | Free | 4 deps |
