Radar <mv-radar>

Tela de radar WebGL desenhada com os tokens do tema: um feixe gira no sentido horário a partir do norte sobre anéis de distância tracejados e uma escala de bússola, ecos espalhados ao longo do arco se acendem quando ele passa e se apagam até a próxima volta, contatos em movimento deixam um histórico de plotagens e um vetor de velocidade, e ecos parasitas granulados respondem perto do centro.

Como funciona

Tela de radar WebGL desenhada com os tokens do tema: um feixe gira no sentido horário a partir do norte sobre anéis de distância tracejados e uma escala de bússola, ecos espalhados ao longo do arco se acendem quando ele passa e se apagam até a próxima volta, contatos em movimento deixam um histórico de plotagens e um vetor de velocidade, e ecos parasitas granulados respondem perto do centro. O ponteiro carrega um anel de distância e uma linha de marcação, e trava uma janela no contato abaixo dele. Os apps podem plotar seus próprios contatos, alertas incluídos. Funciona em temas claros e escuros.

CategoriaFundos
TipoElemento WebGL (<mv-radar>)
Statusestável
Também instalashader
Keywordssafe-rewrite, webgl, shader, radar, sweep, scope, monitoring, hud, tech, interactive

When to use

  • A monitoring, security or logistics hero wants a calm scanning scope behind the headline, in light or dark themes
  • A status panel should plot a few real items (services, vehicles, sensors) by distance and direction, with alerts flagged
  • A search or discovery screen needs a sense of scanning while results load

Avoid when

  • Real places must be shown on a map; the scope only knows range and bearing → use World Map instead
  • Concentric ripples over a grid are wanted without a rotating beam → use Ripple Grid instead
  • The contacts are data that people must read; the canvas is decorative, so give the same data as text or a table

Instalação

node scripts/add.mjs radar --out ./src/marvelous

Agente de IA com o servidor MCP do Marvelous UI: install_components({ slugs: ["radar"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).

Arquivos copiados (dependências incluídas): tokens/tokens.css, core/base.css, core/canvas.js, core/dom.js, core/element.js, core/i18n.js, core/motion.js, core/observe.js, core/webgl.js, components/shader/shader.js, components/shader/shader.css, components/radar/radar.js, components/radar/radar.css.

Uso

Marcação de referência, para usar como ponto de partida e personalizar com atributos, data-* e variáveis CSS:

<div style="display:flex;flex-wrap:wrap;min-height:320px">
  <section style="flex:1.6 1 22rem;position:relative;display:flex;align-items:center;overflow:hidden;padding:2rem 1.75rem;min-height:320px">
    <mv-radar data-fill origin="0.74 0.5"></mv-radar>
    <div style="position:relative;max-width:18rem">
      <p style="margin:0;font:700 clamp(1.6rem,4vw,2.4rem)/1.1 var(--mv-font-sans);letter-spacing:-.03em">Nothing slips past</p>
      <p style="margin:.6rem 0 1.2rem;color:var(--mv-fg-muted)">Every service, swept every six seconds. Point at a contact to lock on.</p>
      <a class="mv-button" href="#radar">Start monitoring</a>
    </div>
  </section>
  <section style="flex:1 1 14rem;position:relative;display:grid;place-items:end center;text-align:center;overflow:hidden;border-left:1px solid var(--mv-border);min-height:260px;padding:1rem">
    <mv-radar data-fill origin="0.5 0.6" scale="0.78" rings="3" blips="0" clutter="0" targets="0.35 40, 0.62 128 1.4, 0.8 250 1 alert, 0.5 312"></mv-radar>
    <div style="position:relative">
      <strong style="display:block;font-size:.95rem">Your own contacts</strong>
      <span style="font-size:.8rem;color:var(--mv-fg-muted)">targets="0.8 250 1 alert, …"</span>
    </div>
  </section>
</div>

API

Attributes

NameTipoDefaultDescription
colorCSS colorvar(--mv-accent)Accent of the beam, echoes, compass marker and pointer tools (tokens accepted, read again on theme change).
backgroundCSS colorvar(--mv-bg)Paper color under the scope (tokens accepted).
line-colorCSS colorvar(--mv-fg)Ink of the rings, spokes and compass scale, drawn at low opacity over the paper (tokens accepted).
alert-colorCSS colorvar(--mv-danger)Color of contacts marked alert in targets (tokens accepted).
ringsnumber4Number of range rings, the rim included (1 to 12).
blipsnumber7Number of decorative contacts (0 to 12); about a third stay fixed, the others patrol. 0 keeps only targets.
targetsstringYour own contacts, up to 8: "range bearing [strength] [alert]" separated by commas, e.g. "0.4 30, 0.8 250 1 alert". Range 0..1 of the scope, bearing in degrees clockwise from north, strength 0 to 2 (default 1). Also a JS property (array of { range, bearing, strength, alert }).
scalenumber1Scope size relative to the element height.
trailnumber1Length of the beam's afterglow and how long echoes persist (0.1 to 3).
clutternumber0.5Grainy returns around the center, 0 to 1 (0 turns them off).
originx y0.5 0.5Scope center in 0..1 element coordinates (y pointing up), e.g. "0.7 0.5" to leave room for a headline.
speednumber1Time multiplier (one turn takes 6 s at 1).
pausedbooleanFreezes the animation on the current frame.
interactivebooleanPointer tools follow the pointer only over the element itself (otherwise across the window).
dprnumber1.5Max pixel density (capped at 2).
data-fillbooleanFills the positioned parent (absolute, inset 0).

Properties

NameTipoDescription
targetsArray<{ range, bearing, strength?, alert? }>Reads or sets the app contacts; setting it rewrites the targets attribute. Values are clamped (range 0..1, strength 0..2) and only the first 8 are drawn.

Events

NameDescription
mv-errorInherited from <mv-shader>: the GLSL failed to compile. The element shows its still fallback scope.

Content structure

NameDescription
childrenContent placed inside the element sits above the scope.

Accessibility

Decorative: the canvas is aria-hidden and never takes pointer events, so content placed above it stays clickable and in reading order. Contacts plotted with targets are not announced: give the same data as text (a list or table) when people need it. The loop stops off screen and in hidden tabs, and no WebGL context is created until the element nears the viewport. Reduced motion (OS or <html data-motion="reduce">) and paused keep a still frame with the beam to the north-east and the contacts painted. Without WebGL2 a still CSS scope is shown; forced colors and print hide the canvas. Keep headline text in the theme foreground, which the faint scope leaves readable; the beam passes behind it at low opacity.

Esta página foi traduzida com IA. Informar um problema de tradução