dc78d8fea3
Componentes React reutilizables: card, dialog, tabs, select, alert, badge, button, input, label, skeleton, tooltip, progress_bar, page_header, form_field, settings_page, crud_page, analytics_page, dashboard_layout. Charts: area, bar, line, sparkline, kpi_card, chart_container. Hooks Wails: use_wails_query, use_wails_mutation, use_wails_stream, use_wails_event, use_animated_canvas. Funciones core: cn, format_compact, chart_colors, get_series_color, wails_cache, theme_config_to_colors. Tipos: chart_series, wails_ipc, theme_config, component_variants. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1.6 KiB
1.6 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path, props, emits, has_state, framework, variant
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | tested | tests | test_file_path | file_path | props | emits | has_state | framework | variant | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| use_animated_canvas | component | typescript | ui | 1.0.0 | impure | useAnimatedCanvas(options: AnimatedCanvasOptions): AnimatedCanvasResult | Hook React para canvas animado a N fps via requestAnimationFrame. Maneja DPR, resize, throttling, y contador de FPS real. |
|
false |
|
false | frontend/functions/ui/use_animated_canvas.tsx |
|
true | react |
|
Ejemplo
const { canvasRef, renderFpsRef } = useAnimatedCanvas({
fps: 100,
draw: (ctx, w, h) => {
// Dibujar lo que sea a 100fps
ctx.fillStyle = '#3b82f6'
ctx.fillRect(0, 0, w * Math.random(), h)
},
})
return <canvas ref={canvasRef} style={{ width: '100%', height: 300 }} />
Notas
- DPR automático: escala el canvas al devicePixelRatio de la pantalla
- Resize automático: detecta cambios de tamaño via getBoundingClientRect
- Throttle configurable: rAF corre a ~144fps nativo, el hook filtra a N fps
- FPS real:
renderFpsRef.currenttiene los FPS medidos (no el target) - drawRef pattern: actualiza el callback sin re-crear el loop de animación