trama-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CATALOG.md +1237 -0
- package/LICENSE +21 -0
- package/README.md +78 -0
- package/THIRD-PARTY.md +4 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/brown.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/brown_inlay.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/brown_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/grey.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/grey_inlay.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/grey_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/tan.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/tan_inlay.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/tan_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/white.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/white_inlay.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Ancient/white_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/blue.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/blue_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/green.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/green_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/grey.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/grey_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/red.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/red_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/yellow.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Colored/yellow_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Outline/blue.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Outline/blue_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Outline/green.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Outline/green_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Outline/red.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Outline/red_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Outline/yellow.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/Outline/yellow_pressed.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/list.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/space.png +0 -0
- package/assets/pixel/kenney-pixel-ui/9-slice/space_inlay.png +0 -0
- package/assets/pixel/kenney-pixel-ui/License.txt +23 -0
- package/assets/pixel/kenney-pixel-ui/spritesheet/sheet.png +0 -0
- package/bin/trama-ui.mjs +27 -0
- package/dist/components/ui/Accordion.d.ts +12 -0
- package/dist/components/ui/Accordion.js +12 -0
- package/dist/components/ui/Alert.d.ts +15 -0
- package/dist/components/ui/Alert.js +15 -0
- package/dist/components/ui/ArticlesSection.d.ts +30 -0
- package/dist/components/ui/ArticlesSection.js +18 -0
- package/dist/components/ui/AsciiBackground.d.ts +58 -0
- package/dist/components/ui/AsciiBackground.js +173 -0
- package/dist/components/ui/AsciiCard.d.ts +78 -0
- package/dist/components/ui/AsciiCard.js +253 -0
- package/dist/components/ui/AsciiChart.d.ts +18 -0
- package/dist/components/ui/AsciiChart.js +47 -0
- package/dist/components/ui/Badge.d.ts +15 -0
- package/dist/components/ui/Badge.js +8 -0
- package/dist/components/ui/BitmapText.d.ts +25 -0
- package/dist/components/ui/BitmapText.js +21 -0
- package/dist/components/ui/BlogCard.d.ts +33 -0
- package/dist/components/ui/BlogCard.js +13 -0
- package/dist/components/ui/Breadcrumbs.d.ts +9 -0
- package/dist/components/ui/Breadcrumbs.js +7 -0
- package/dist/components/ui/Button.d.ts +74 -0
- package/dist/components/ui/Button.js +48 -0
- package/dist/components/ui/CTASection.d.ts +13 -0
- package/dist/components/ui/CTASection.js +7 -0
- package/dist/components/ui/Carousel.d.ts +30 -0
- package/dist/components/ui/Carousel.js +80 -0
- package/dist/components/ui/CheckboxGroup.d.ts +11 -0
- package/dist/components/ui/CheckboxGroup.js +20 -0
- package/dist/components/ui/CodeBlock.d.ts +11 -0
- package/dist/components/ui/CodeBlock.js +20 -0
- package/dist/components/ui/ContactForm.d.ts +25 -0
- package/dist/components/ui/ContactForm.js +26 -0
- package/dist/components/ui/CrtOverlay.d.ts +10 -0
- package/dist/components/ui/CrtOverlay.js +5 -0
- package/dist/components/ui/Divider.d.ts +12 -0
- package/dist/components/ui/Divider.js +7 -0
- package/dist/components/ui/Drawer.d.ts +16 -0
- package/dist/components/ui/Drawer.js +25 -0
- package/dist/components/ui/Dropdown.d.ts +10 -0
- package/dist/components/ui/Dropdown.js +21 -0
- package/dist/components/ui/FAQSection.d.ts +14 -0
- package/dist/components/ui/FAQSection.js +7 -0
- package/dist/components/ui/FeatureGrid.d.ts +18 -0
- package/dist/components/ui/FeatureGrid.js +14 -0
- package/dist/components/ui/Footer.d.ts +14 -0
- package/dist/components/ui/Footer.js +16 -0
- package/dist/components/ui/GlyphCursor.d.ts +22 -0
- package/dist/components/ui/GlyphCursor.js +50 -0
- package/dist/components/ui/GridBackground.d.ts +15 -0
- package/dist/components/ui/GridBackground.js +6 -0
- package/dist/components/ui/Hero.d.ts +21 -0
- package/dist/components/ui/Hero.js +12 -0
- package/dist/components/ui/HoverFX.d.ts +29 -0
- package/dist/components/ui/HoverFX.js +75 -0
- package/dist/components/ui/Icon.d.ts +33 -0
- package/dist/components/ui/Icon.js +29 -0
- package/dist/components/ui/ImageGallery.d.ts +31 -0
- package/dist/components/ui/ImageGallery.js +79 -0
- package/dist/components/ui/LogoCloud.d.ts +12 -0
- package/dist/components/ui/LogoCloud.js +9 -0
- package/dist/components/ui/MagneticButton.d.ts +12 -0
- package/dist/components/ui/MagneticButton.js +49 -0
- package/dist/components/ui/Marquee.d.ts +29 -0
- package/dist/components/ui/Marquee.js +15 -0
- package/dist/components/ui/Modal.d.ts +40 -0
- package/dist/components/ui/Modal.js +51 -0
- package/dist/components/ui/NavBar.d.ts +14 -0
- package/dist/components/ui/NavBar.js +12 -0
- package/dist/components/ui/NeonSign.d.ts +14 -0
- package/dist/components/ui/NeonSign.js +7 -0
- package/dist/components/ui/OtpInput.d.ts +9 -0
- package/dist/components/ui/OtpInput.js +27 -0
- package/dist/components/ui/Pagination.d.ts +10 -0
- package/dist/components/ui/Pagination.js +24 -0
- package/dist/components/ui/Panel.d.ts +21 -0
- package/dist/components/ui/Panel.js +8 -0
- package/dist/components/ui/PixelFrame.d.ts +61 -0
- package/dist/components/ui/PixelFrame.js +29 -0
- package/dist/components/ui/Presence.d.ts +51 -0
- package/dist/components/ui/Presence.js +343 -0
- package/dist/components/ui/PricingCard.d.ts +30 -0
- package/dist/components/ui/PricingCard.js +21 -0
- package/dist/components/ui/PricingSection.d.ts +35 -0
- package/dist/components/ui/PricingSection.js +21 -0
- package/dist/components/ui/Progress.d.ts +17 -0
- package/dist/components/ui/Progress.js +9 -0
- package/dist/components/ui/RadioGroup.d.ts +10 -0
- package/dist/components/ui/RadioGroup.js +11 -0
- package/dist/components/ui/RangeSlider.d.ts +14 -0
- package/dist/components/ui/RangeSlider.js +11 -0
- package/dist/components/ui/Reveal.d.ts +48 -0
- package/dist/components/ui/Reveal.js +181 -0
- package/dist/components/ui/SceneFlash.d.ts +14 -0
- package/dist/components/ui/SceneFlash.js +51 -0
- package/dist/components/ui/ScrambleText.d.ts +31 -0
- package/dist/components/ui/ScrambleText.js +51 -0
- package/dist/components/ui/ScrollArea.d.ts +15 -0
- package/dist/components/ui/ScrollArea.js +18 -0
- package/dist/components/ui/SectionHeader.d.ts +12 -0
- package/dist/components/ui/SectionHeader.js +6 -0
- package/dist/components/ui/Select.d.ts +17 -0
- package/dist/components/ui/Select.js +31 -0
- package/dist/components/ui/Skeleton.d.ts +12 -0
- package/dist/components/ui/Skeleton.js +18 -0
- package/dist/components/ui/Spinner.d.ts +15 -0
- package/dist/components/ui/Spinner.js +24 -0
- package/dist/components/ui/Spotlight.d.ts +16 -0
- package/dist/components/ui/Spotlight.js +16 -0
- package/dist/components/ui/Sprite.d.ts +27 -0
- package/dist/components/ui/Sprite.js +19 -0
- package/dist/components/ui/StatCounter.d.ts +24 -0
- package/dist/components/ui/StatCounter.js +70 -0
- package/dist/components/ui/StatsSection.d.ts +14 -0
- package/dist/components/ui/StatsSection.js +13 -0
- package/dist/components/ui/Stepper.d.ts +10 -0
- package/dist/components/ui/Stepper.js +7 -0
- package/dist/components/ui/Table.d.ts +10 -0
- package/dist/components/ui/Table.js +8 -0
- package/dist/components/ui/Tabs.d.ts +12 -0
- package/dist/components/ui/Tabs.js +18 -0
- package/dist/components/ui/TeamSection.d.ts +18 -0
- package/dist/components/ui/TeamSection.js +19 -0
- package/dist/components/ui/TerminalTyper.d.ts +20 -0
- package/dist/components/ui/TerminalTyper.js +45 -0
- package/dist/components/ui/Testimonial.d.ts +19 -0
- package/dist/components/ui/Testimonial.js +9 -0
- package/dist/components/ui/TestimonialSection.d.ts +20 -0
- package/dist/components/ui/TestimonialSection.js +15 -0
- package/dist/components/ui/TextField.d.ts +26 -0
- package/dist/components/ui/TextField.js +13 -0
- package/dist/components/ui/TextmodeBackground.d.ts +52 -0
- package/dist/components/ui/TextmodeBackground.js +83 -0
- package/dist/components/ui/Timeline.d.ts +13 -0
- package/dist/components/ui/Timeline.js +8 -0
- package/dist/components/ui/Toast.d.ts +30 -0
- package/dist/components/ui/Toast.js +47 -0
- package/dist/components/ui/Toggle.d.ts +13 -0
- package/dist/components/ui/Toggle.js +10 -0
- package/dist/components/ui/Tooltip.d.ts +20 -0
- package/dist/components/ui/Tooltip.js +20 -0
- package/dist/components/ui/Typewriter.d.ts +20 -0
- package/dist/components/ui/Typewriter.js +46 -0
- package/dist/components/ui/VideoPlayer.d.ts +81 -0
- package/dist/components/ui/VideoPlayer.js +379 -0
- package/dist/components/ui/fill.d.ts +32 -0
- package/dist/components/ui/fill.js +27 -0
- package/dist/components/ui/intent.d.ts +20 -0
- package/dist/components/ui/intent.js +23 -0
- package/dist/components/ui/styles/kit.css +31 -0
- package/dist/components/ui/styles/ui-carousel.css +113 -0
- package/dist/components/ui/styles/ui-kit.css +1135 -0
- package/dist/components/ui/styles/ui-video.css +75 -0
- package/dist/components/ui/swiperCss.d.ts +15 -0
- package/dist/components/ui/swiperCss.js +15 -0
- package/dist/components/ui/variants.d.ts +12 -0
- package/dist/components/ui/variants.js +10 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +77 -0
- package/dist/lib/asciify/painters.d.ts +25 -0
- package/dist/lib/asciify/painters.js +604 -0
- package/dist/lib/asciify/pointer.d.ts +12 -0
- package/dist/lib/asciify/pointer.js +54 -0
- package/dist/lib/asciify/shape-painters.d.ts +44 -0
- package/dist/lib/asciify/shape-painters.js +335 -0
- package/dist/lib/asciify/theme-painters.d.ts +8 -0
- package/dist/lib/asciify/theme-painters.js +437 -0
- package/dist/lib/cells.d.ts +46 -0
- package/dist/lib/cells.js +114 -0
- package/dist/lib/scroll/store.d.ts +21 -0
- package/dist/lib/scroll/store.js +25 -0
- package/dist/lib/sketches/aurora.d.ts +3 -0
- package/dist/lib/sketches/aurora.js +42 -0
- package/dist/lib/sketches/fire.d.ts +3 -0
- package/dist/lib/sketches/fire.js +80 -0
- package/dist/lib/sketches/flow.d.ts +3 -0
- package/dist/lib/sketches/flow.js +70 -0
- package/dist/lib/sketches/life.d.ts +3 -0
- package/dist/lib/sketches/life.js +107 -0
- package/dist/lib/sketches/matrix.d.ts +3 -0
- package/dist/lib/sketches/matrix.js +64 -0
- package/dist/lib/sketches/ocean.d.ts +3 -0
- package/dist/lib/sketches/ocean.js +56 -0
- package/dist/lib/sketches/plasma.d.ts +3 -0
- package/dist/lib/sketches/plasma.js +29 -0
- package/dist/lib/sketches/registry.d.ts +6 -0
- package/dist/lib/sketches/registry.js +60 -0
- package/dist/lib/sketches/ripples.d.ts +3 -0
- package/dist/lib/sketches/ripples.js +84 -0
- package/dist/lib/sketches/scroll-assemble.d.ts +8 -0
- package/dist/lib/sketches/scroll-assemble.js +90 -0
- package/dist/lib/sketches/scroll-parallax.d.ts +6 -0
- package/dist/lib/sketches/scroll-parallax.js +76 -0
- package/dist/lib/sketches/scroll-rain.d.ts +6 -0
- package/dist/lib/sketches/scroll-rain.js +82 -0
- package/dist/lib/sketches/scroll-stats.d.ts +7 -0
- package/dist/lib/sketches/scroll-stats.js +81 -0
- package/dist/lib/sketches/scroll-terminal.d.ts +6 -0
- package/dist/lib/sketches/scroll-terminal.js +87 -0
- package/dist/lib/sketches/scroll-zoom.d.ts +7 -0
- package/dist/lib/sketches/scroll-zoom.js +49 -0
- package/dist/lib/sketches/starfield.d.ts +3 -0
- package/dist/lib/sketches/starfield.js +54 -0
- package/dist/lib/sketches/text-3d.d.ts +6 -0
- package/dist/lib/sketches/text-3d.js +62 -0
- package/dist/lib/sketches/text-combo-figlet.d.ts +6 -0
- package/dist/lib/sketches/text-combo-figlet.js +91 -0
- package/dist/lib/sketches/text-glitch.d.ts +3 -0
- package/dist/lib/sketches/text-glitch.js +57 -0
- package/dist/lib/sketches/text-marquee.d.ts +3 -0
- package/dist/lib/sketches/text-marquee.js +35 -0
- package/dist/lib/sketches/text-particles.d.ts +9 -0
- package/dist/lib/sketches/text-particles.js +91 -0
- package/dist/lib/sketches/text-rain.d.ts +3 -0
- package/dist/lib/sketches/text-rain.js +73 -0
- package/dist/lib/sketches/text-scramble.d.ts +6 -0
- package/dist/lib/sketches/text-scramble.js +49 -0
- package/dist/lib/sketches/text-wave.d.ts +3 -0
- package/dist/lib/sketches/text-wave.js +43 -0
- package/dist/lib/sketches/theme-orbit.d.ts +6 -0
- package/dist/lib/sketches/theme-orbit.js +119 -0
- package/dist/lib/sketches/theme-pulse.d.ts +7 -0
- package/dist/lib/sketches/theme-pulse.js +84 -0
- package/dist/lib/sketches/tunnel.d.ts +3 -0
- package/dist/lib/sketches/tunnel.js +28 -0
- package/dist/lib/text/banner.d.ts +5 -0
- package/dist/lib/text/banner.js +35 -0
- package/dist/lib/text/mask.d.ts +40 -0
- package/dist/lib/text/mask.js +143 -0
- package/dist/lib/text/store.d.ts +23 -0
- package/dist/lib/text/store.js +86 -0
- package/dist/lib/ui/card-fields.d.ts +52 -0
- package/dist/lib/ui/card-fields.js +193 -0
- package/dist/lib/ui/fonts.d.ts +56 -0
- package/dist/lib/ui/fonts.js +94 -0
- package/dist/lib/ui/fx.d.ts +42 -0
- package/dist/lib/ui/fx.js +162 -0
- package/dist/lib/ui/icons.d.ts +437 -0
- package/dist/lib/ui/icons.js +314 -0
- package/dist/lib/ui/placeholder.d.ts +11 -0
- package/dist/lib/ui/placeholder.js +65 -0
- package/dist/lib/ui/tokens.d.ts +49 -0
- package/dist/lib/ui/tokens.js +129 -0
- package/dist/lib/ui/useTokens.d.ts +10 -0
- package/dist/lib/ui/useTokens.js +32 -0
- package/package.json +80 -0
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fuentes procedurales para asciify-engine.
|
|
3
|
+
*
|
|
4
|
+
* asciify-engine convierte imágenes, vídeo o canvas en arte de caracteres. Como el
|
|
5
|
+
* proyecto no trae medios, cada demo dibuja su propia imagen animada en un canvas 2D
|
|
6
|
+
* y el motor la convierte en cada fotograma.
|
|
7
|
+
*/
|
|
8
|
+
import { BOLD_FONT, fitLines } from "../text/mask.js";
|
|
9
|
+
import { scrollState } from "../scroll/store.js";
|
|
10
|
+
import { themePainters } from "./theme-painters.js";
|
|
11
|
+
import { shapePainters } from "./shape-painters.js";
|
|
12
|
+
import { textStore } from "../text/store.js";
|
|
13
|
+
const TAU = Math.PI * 2;
|
|
14
|
+
function fillBg(ctx, w, h, color) {
|
|
15
|
+
ctx.globalCompositeOperation = "source-over";
|
|
16
|
+
ctx.globalAlpha = 1;
|
|
17
|
+
ctx.fillStyle = color;
|
|
18
|
+
ctx.fillRect(0, 0, w, h);
|
|
19
|
+
}
|
|
20
|
+
/** Metaballs de lava: gradientes radiales sumados. El puntero arrastra una gota grande. */
|
|
21
|
+
const lava = () => {
|
|
22
|
+
const balls = Array.from({ length: 9 }, (_, i) => ({
|
|
23
|
+
fx: 0.25 + i * 0.09,
|
|
24
|
+
fy: 0.2 + ((i * 37) % 9) * 0.05,
|
|
25
|
+
ph: i * 1.7,
|
|
26
|
+
r: 0.12 + (((i * 53) % 7) / 7) * 0.09,
|
|
27
|
+
}));
|
|
28
|
+
return (ctx, w, h, t, p) => {
|
|
29
|
+
fillBg(ctx, w, h, "#12061f");
|
|
30
|
+
ctx.globalCompositeOperation = "lighter";
|
|
31
|
+
const R = Math.min(w, h);
|
|
32
|
+
const blob = (x, y, r, hue, a) => {
|
|
33
|
+
const g = ctx.createRadialGradient(x, y, 0, x, y, r);
|
|
34
|
+
g.addColorStop(0, `hsla(${hue},100%,60%,${a})`);
|
|
35
|
+
g.addColorStop(0.55, `hsla(${hue + 20},100%,45%,${a * 0.55})`);
|
|
36
|
+
g.addColorStop(1, `hsla(${hue + 40},100%,35%,0)`);
|
|
37
|
+
ctx.fillStyle = g;
|
|
38
|
+
ctx.beginPath();
|
|
39
|
+
ctx.arc(x, y, r, 0, TAU);
|
|
40
|
+
ctx.fill();
|
|
41
|
+
};
|
|
42
|
+
balls.forEach((b, i) => {
|
|
43
|
+
const x = w * (0.5 + 0.42 * Math.sin(t * b.fx + b.ph));
|
|
44
|
+
const y = h * (0.5 + 0.4 * Math.cos(t * b.fy * 1.3 + b.ph * 1.3));
|
|
45
|
+
blob(x, y, R * b.r * 1.7, (t * 14 + i * 32) % 360, 0.9);
|
|
46
|
+
});
|
|
47
|
+
blob(p.x * w, p.y * h, R * (p.down ? 0.34 : 0.24), 45, 1);
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Atardecer synthwave: sol a franjas, montañas y rejilla en perspectiva. */
|
|
51
|
+
const synthwave = () => (ctx, w, h, t, p) => {
|
|
52
|
+
const hz = h * 0.56;
|
|
53
|
+
const sky = ctx.createLinearGradient(0, 0, 0, hz);
|
|
54
|
+
sky.addColorStop(0, "#07011c");
|
|
55
|
+
sky.addColorStop(0.55, "#4b0f6b");
|
|
56
|
+
sky.addColorStop(1, "#ff3d81");
|
|
57
|
+
ctx.globalCompositeOperation = "source-over";
|
|
58
|
+
ctx.fillStyle = sky;
|
|
59
|
+
ctx.fillRect(0, 0, w, hz);
|
|
60
|
+
// Sol
|
|
61
|
+
const sx = w * (0.5 + (p.x - 0.5) * 0.12);
|
|
62
|
+
const sr = h * 0.27;
|
|
63
|
+
const sun = ctx.createLinearGradient(0, hz - sr * 1.9, 0, hz);
|
|
64
|
+
sun.addColorStop(0, "#fff36b");
|
|
65
|
+
sun.addColorStop(1, "#ff2d95");
|
|
66
|
+
ctx.fillStyle = sun;
|
|
67
|
+
ctx.beginPath();
|
|
68
|
+
ctx.arc(sx, hz - sr * 0.9, sr, 0, TAU);
|
|
69
|
+
ctx.fill();
|
|
70
|
+
// Franjas que se ensanchan hacia abajo y se desplazan
|
|
71
|
+
ctx.fillStyle = "#4b0f6b";
|
|
72
|
+
for (let i = 0; i < 7; i++) {
|
|
73
|
+
const k = ((i + (t * 0.25) % 1) / 7) ** 1.6;
|
|
74
|
+
const y = hz - sr * 1.9 + sr * 1.9 * (0.35 + 0.65 * k);
|
|
75
|
+
ctx.fillRect(sx - sr, y, sr * 2, 2 + k * sr * 0.16);
|
|
76
|
+
}
|
|
77
|
+
// Montañas
|
|
78
|
+
ctx.fillStyle = "#16042e";
|
|
79
|
+
ctx.beginPath();
|
|
80
|
+
ctx.moveTo(0, hz);
|
|
81
|
+
for (let x = 0; x <= w; x += 6) {
|
|
82
|
+
const m = Math.abs(Math.sin(x * 0.012 + 1) * 0.6 + Math.sin(x * 0.031) * 0.4);
|
|
83
|
+
ctx.lineTo(x, hz - m * h * 0.11);
|
|
84
|
+
}
|
|
85
|
+
ctx.lineTo(w, hz);
|
|
86
|
+
ctx.fill();
|
|
87
|
+
// Suelo y rejilla
|
|
88
|
+
ctx.fillStyle = "#0d0224";
|
|
89
|
+
ctx.fillRect(0, hz, w, h - hz);
|
|
90
|
+
ctx.strokeStyle = "#ff2bd6";
|
|
91
|
+
ctx.lineWidth = Math.max(1, h * 0.006);
|
|
92
|
+
ctx.beginPath();
|
|
93
|
+
const N = 14;
|
|
94
|
+
for (let i = 0; i < N; i++) {
|
|
95
|
+
const k = ((i + ((t * 0.5) % 1)) / N) ** 2.2;
|
|
96
|
+
const y = hz + (h - hz) * k;
|
|
97
|
+
ctx.moveTo(0, y);
|
|
98
|
+
ctx.lineTo(w, y);
|
|
99
|
+
}
|
|
100
|
+
for (let k = -16; k <= 16; k++) {
|
|
101
|
+
ctx.moveTo(w / 2 + k * w * 0.012, hz);
|
|
102
|
+
ctx.lineTo(w / 2 + k * w * 0.17, h);
|
|
103
|
+
}
|
|
104
|
+
ctx.stroke();
|
|
105
|
+
const glow = ctx.createLinearGradient(0, hz - 4, 0, hz + h * 0.08);
|
|
106
|
+
glow.addColorStop(0, "rgba(255,120,220,0.9)");
|
|
107
|
+
glow.addColorStop(1, "rgba(255,120,220,0)");
|
|
108
|
+
ctx.fillStyle = glow;
|
|
109
|
+
ctx.fillRect(0, hz - 4, w, h * 0.08);
|
|
110
|
+
};
|
|
111
|
+
/** Galaxia espiral con brazos y núcleo brillante. El puntero mueve el centro. */
|
|
112
|
+
const galaxy = () => {
|
|
113
|
+
const stars = Array.from({ length: 3400 }, (_, i) => {
|
|
114
|
+
const r = Math.random() ** 0.65;
|
|
115
|
+
const arm = i % 3;
|
|
116
|
+
const jitter = (Math.random() + Math.random() + Math.random() - 1.5) * 0.5;
|
|
117
|
+
return {
|
|
118
|
+
r,
|
|
119
|
+
a: (arm * TAU) / 3 + r * 5.2 + jitter,
|
|
120
|
+
hue: 200 + r * 120 + Math.random() * 30,
|
|
121
|
+
sz: 2.2 + Math.random() * 3.2,
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
return (ctx, w, h, t, p) => {
|
|
125
|
+
fillBg(ctx, w, h, "#03030c");
|
|
126
|
+
ctx.globalCompositeOperation = "lighter";
|
|
127
|
+
const cx = w * (0.5 + (p.x - 0.5) * 0.3);
|
|
128
|
+
const cy = h * (0.5 + (p.y - 0.5) * 0.3);
|
|
129
|
+
const R = Math.max(w, h) * 0.52;
|
|
130
|
+
const core = ctx.createRadialGradient(cx, cy, 0, cx, cy, R * 0.35);
|
|
131
|
+
core.addColorStop(0, "rgba(255,240,200,0.95)");
|
|
132
|
+
core.addColorStop(0.3, "rgba(255,150,90,0.4)");
|
|
133
|
+
core.addColorStop(1, "rgba(80,40,160,0)");
|
|
134
|
+
ctx.fillStyle = core;
|
|
135
|
+
ctx.fillRect(0, 0, w, h);
|
|
136
|
+
for (const s of stars) {
|
|
137
|
+
const ang = s.a + t * (0.05 + 0.5 / (s.r * 6 + 0.6));
|
|
138
|
+
const x = cx + Math.cos(ang) * s.r * R;
|
|
139
|
+
const y = cy + Math.sin(ang) * s.r * R * 0.58;
|
|
140
|
+
ctx.fillStyle = `hsl(${s.hue},90%,${65 + (1 - s.r) * 25}%)`;
|
|
141
|
+
ctx.fillRect(x, y, s.sz * (w / 640), s.sz * (w / 640));
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
/** Bandas de olas apiladas con degradados. El puntero levanta una cresta. */
|
|
146
|
+
const waves = () => (ctx, w, h, t, p) => {
|
|
147
|
+
const bg = ctx.createLinearGradient(0, 0, 0, h);
|
|
148
|
+
bg.addColorStop(0, "#0a0a2a");
|
|
149
|
+
bg.addColorStop(1, "#1a0b30");
|
|
150
|
+
ctx.globalCompositeOperation = "source-over";
|
|
151
|
+
ctx.fillStyle = bg;
|
|
152
|
+
ctx.fillRect(0, 0, w, h);
|
|
153
|
+
const bands = 7;
|
|
154
|
+
for (let i = 0; i < bands; i++) {
|
|
155
|
+
const y0 = h * (0.22 + i * 0.1);
|
|
156
|
+
const amp = h * (0.035 + i * 0.012);
|
|
157
|
+
const hue = (t * 12 + i * 34) % 360;
|
|
158
|
+
const g = ctx.createLinearGradient(0, y0 - amp, 0, h);
|
|
159
|
+
g.addColorStop(0, `hsl(${hue},90%,${62 - i * 3}%)`);
|
|
160
|
+
g.addColorStop(1, `hsl(${hue + 30},80%,${22 - i}%)`);
|
|
161
|
+
ctx.fillStyle = g;
|
|
162
|
+
ctx.beginPath();
|
|
163
|
+
ctx.moveTo(0, h);
|
|
164
|
+
for (let x = 0; x <= w; x += 6) {
|
|
165
|
+
const nx = x / w;
|
|
166
|
+
const bump = Math.exp(-(((nx - p.x) * 5) ** 2)) * h * (p.down ? 0.2 : 0.09) * Math.sin(t * 3 + i);
|
|
167
|
+
const y = y0 +
|
|
168
|
+
Math.sin(x * 0.013 * (1 + i * 0.12) + t * (0.6 + i * 0.13) + i) * amp +
|
|
169
|
+
Math.sin(x * 0.035 - t * 0.9 + i * 2) * amp * 0.3 -
|
|
170
|
+
bump;
|
|
171
|
+
ctx.lineTo(x, y);
|
|
172
|
+
}
|
|
173
|
+
ctx.lineTo(w, h);
|
|
174
|
+
ctx.closePath();
|
|
175
|
+
ctx.fill();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
/** Anillos concéntricos giratorios que crecen desde el puntero. */
|
|
179
|
+
const rings = () => (ctx, w, h, t, p) => {
|
|
180
|
+
fillBg(ctx, w, h, "#050510");
|
|
181
|
+
const cx = w * p.x;
|
|
182
|
+
const cy = h * p.y;
|
|
183
|
+
const R = Math.hypot(Math.max(cx, w - cx), Math.max(cy, h - cy));
|
|
184
|
+
const N = 22;
|
|
185
|
+
ctx.lineCap = "round";
|
|
186
|
+
for (let i = 0; i < N; i++) {
|
|
187
|
+
const k = (i + ((t * 0.6) % 1)) / N;
|
|
188
|
+
const r = k * R;
|
|
189
|
+
const rot = t * (i % 2 ? 1 : -1) * 0.8 + i;
|
|
190
|
+
ctx.strokeStyle = `hsla(${(i * 22 + t * 40) % 360},95%,60%,${1 - k * 0.7})`;
|
|
191
|
+
ctx.lineWidth = 2 + k * Math.min(w, h) * 0.05 * (p.down ? 1.6 : 1);
|
|
192
|
+
ctx.beginPath();
|
|
193
|
+
ctx.arc(cx, cy, r, rot, rot + Math.PI * 1.35);
|
|
194
|
+
ctx.stroke();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
/** Plasma calculado por píxel a baja resolución. El puntero crea una onda. */
|
|
198
|
+
const plasma = () => {
|
|
199
|
+
let buf = null;
|
|
200
|
+
return (ctx, w, h, t, p) => {
|
|
201
|
+
const bw = 200;
|
|
202
|
+
const bh = Math.max(2, Math.round((bw * h) / w));
|
|
203
|
+
if (!buf || buf.width !== bw || buf.height !== bh) {
|
|
204
|
+
buf = document.createElement("canvas");
|
|
205
|
+
buf.width = bw;
|
|
206
|
+
buf.height = bh;
|
|
207
|
+
}
|
|
208
|
+
const bctx = buf.getContext("2d");
|
|
209
|
+
const img = bctx.createImageData(bw, bh);
|
|
210
|
+
const d = img.data;
|
|
211
|
+
const aspect = w / h;
|
|
212
|
+
for (let y = 0; y < bh; y++) {
|
|
213
|
+
for (let x = 0; x < bw; x++) {
|
|
214
|
+
const u = x / bw;
|
|
215
|
+
const v = y / bh;
|
|
216
|
+
const dx = (u - p.x) * aspect;
|
|
217
|
+
const dy = v - p.y;
|
|
218
|
+
const dist = Math.hypot(dx, dy);
|
|
219
|
+
const val = Math.sin(u * 9 * aspect * 0.5 + t) +
|
|
220
|
+
Math.sin(v * 11 - t * 1.3) +
|
|
221
|
+
Math.sin((u + v) * 8 + t * 0.7) +
|
|
222
|
+
Math.sin(Math.hypot((u - 0.5) * aspect, v - 0.5) * 14 - t * 1.6) +
|
|
223
|
+
Math.sin(dist * (p.down ? 26 : 16) - t * 4) * (p.active ? 1.2 : 0.5) * Math.exp(-dist * 2.4);
|
|
224
|
+
const n = val * 0.2 + 0.5;
|
|
225
|
+
const hue = (n * 300 + t * 20) % 360;
|
|
226
|
+
// HSL simple → RGB
|
|
227
|
+
const s = 0.85;
|
|
228
|
+
const l = 0.28 + 0.4 * Math.max(0, Math.min(1, n));
|
|
229
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
230
|
+
const hp = hue / 60;
|
|
231
|
+
const xx = c * (1 - Math.abs((hp % 2) - 1));
|
|
232
|
+
let r = 0, g = 0, b = 0;
|
|
233
|
+
if (hp < 1)
|
|
234
|
+
[r, g, b] = [c, xx, 0];
|
|
235
|
+
else if (hp < 2)
|
|
236
|
+
[r, g, b] = [xx, c, 0];
|
|
237
|
+
else if (hp < 3)
|
|
238
|
+
[r, g, b] = [0, c, xx];
|
|
239
|
+
else if (hp < 4)
|
|
240
|
+
[r, g, b] = [0, xx, c];
|
|
241
|
+
else if (hp < 5)
|
|
242
|
+
[r, g, b] = [xx, 0, c];
|
|
243
|
+
else
|
|
244
|
+
[r, g, b] = [c, 0, xx];
|
|
245
|
+
const m = l - c / 2;
|
|
246
|
+
const i = (y * bw + x) * 4;
|
|
247
|
+
d[i] = (r + m) * 255;
|
|
248
|
+
d[i + 1] = (g + m) * 255;
|
|
249
|
+
d[i + 2] = (b + m) * 255;
|
|
250
|
+
d[i + 3] = 255;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
bctx.putImageData(img, 0, 0);
|
|
254
|
+
ctx.globalCompositeOperation = "source-over";
|
|
255
|
+
ctx.imageSmoothingEnabled = true;
|
|
256
|
+
ctx.drawImage(buf, 0, 0, w, h);
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
/** Nube de puntos con forma de toro que gira. El puntero controla la rotación. */
|
|
260
|
+
const torus = () => {
|
|
261
|
+
const pts = [];
|
|
262
|
+
const A = 1;
|
|
263
|
+
const B = 0.42;
|
|
264
|
+
for (let i = 0; i < 70; i++) {
|
|
265
|
+
for (let j = 0; j < 26; j++) {
|
|
266
|
+
const u = (i / 70) * TAU;
|
|
267
|
+
const v = (j / 26) * TAU;
|
|
268
|
+
pts.push({
|
|
269
|
+
x: (A + B * Math.cos(v)) * Math.cos(u),
|
|
270
|
+
y: (A + B * Math.cos(v)) * Math.sin(u),
|
|
271
|
+
z: B * Math.sin(v),
|
|
272
|
+
u,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
let ax = 0;
|
|
277
|
+
let ay = 0;
|
|
278
|
+
return (ctx, w, h, t, p) => {
|
|
279
|
+
const bg = ctx.createRadialGradient(w / 2, h / 2, 0, w / 2, h / 2, Math.max(w, h) * 0.7);
|
|
280
|
+
bg.addColorStop(0, "#150a2e");
|
|
281
|
+
bg.addColorStop(1, "#03020a");
|
|
282
|
+
ctx.globalCompositeOperation = "source-over";
|
|
283
|
+
ctx.fillStyle = bg;
|
|
284
|
+
ctx.fillRect(0, 0, w, h);
|
|
285
|
+
ctx.globalCompositeOperation = "lighter";
|
|
286
|
+
ax += 0.012 + (p.y - 0.5) * 0.03;
|
|
287
|
+
ay += 0.018 + (p.x - 0.5) * 0.04;
|
|
288
|
+
const ca = Math.cos(ax), sa = Math.sin(ax), cb = Math.cos(ay), sb = Math.sin(ay);
|
|
289
|
+
const S = Math.min(w, h) * 0.3 * (p.down ? 1.25 : 1);
|
|
290
|
+
for (const q of pts) {
|
|
291
|
+
// rotación X, luego Y
|
|
292
|
+
const y1 = q.y * ca - q.z * sa;
|
|
293
|
+
const z1 = q.y * sa + q.z * ca;
|
|
294
|
+
const x2 = q.x * cb + z1 * sb;
|
|
295
|
+
const z2 = -q.x * sb + z1 * cb;
|
|
296
|
+
const persp = 3.2 / (3.2 - z2);
|
|
297
|
+
const px = w / 2 + x2 * S * persp;
|
|
298
|
+
const py = h / 2 + y1 * S * persp;
|
|
299
|
+
const light = (z2 + 1.5) / 3;
|
|
300
|
+
ctx.fillStyle = `hsla(${(q.u * 57.3 + t * 30) % 360},90%,${50 + light * 30}%,${0.55 + light * 0.45})`;
|
|
301
|
+
const s = (3 + light * 5) * (w / 640) * persp;
|
|
302
|
+
ctx.fillRect(px - s / 2, py - s / 2, s, s);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
/** Palabras grandes deformadas por una onda vertical. */
|
|
307
|
+
const text = () => {
|
|
308
|
+
const words = ["ASCII", "TEXTO", "ARTE", "RETRO"];
|
|
309
|
+
return (ctx, w, h, t, p) => {
|
|
310
|
+
fillBg(ctx, w, h, "#05060c");
|
|
311
|
+
const period = 4;
|
|
312
|
+
const idx = Math.floor(t / period) % words.length;
|
|
313
|
+
const local = (t % period) / period;
|
|
314
|
+
const fade = Math.min(1, local * 6, (1 - local) * 6);
|
|
315
|
+
const word = words[idx];
|
|
316
|
+
const size = Math.min(h * 0.62, (w * 0.92) / (word.length * 0.66));
|
|
317
|
+
ctx.font = `900 ${size}px "Arial Black", Impact, system-ui, sans-serif`;
|
|
318
|
+
ctx.textAlign = "center";
|
|
319
|
+
ctx.textBaseline = "middle";
|
|
320
|
+
const g = ctx.createLinearGradient(0, h * 0.2, 0, h * 0.8);
|
|
321
|
+
g.addColorStop(0, `hsl(${(t * 30) % 360},95%,65%)`);
|
|
322
|
+
g.addColorStop(1, `hsl(${(t * 30 + 90) % 360},95%,55%)`);
|
|
323
|
+
ctx.fillStyle = g;
|
|
324
|
+
ctx.globalAlpha = fade;
|
|
325
|
+
const amp = w * (0.02 + (p.active ? Math.abs(p.x - 0.5) * 0.12 : 0.01));
|
|
326
|
+
const step = Math.max(2, Math.round(h / 90));
|
|
327
|
+
for (let y = 0; y < h; y += step) {
|
|
328
|
+
const off = Math.sin(y * 0.045 + t * 3) * amp;
|
|
329
|
+
ctx.save();
|
|
330
|
+
ctx.beginPath();
|
|
331
|
+
ctx.rect(0, y, w, step);
|
|
332
|
+
ctx.clip();
|
|
333
|
+
ctx.fillText(word, w / 2 + off, h / 2 + size * 0.04);
|
|
334
|
+
ctx.restore();
|
|
335
|
+
}
|
|
336
|
+
ctx.globalAlpha = 1;
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
/** Caleidoscopio: doce sectores espejados con formas orbitando. */
|
|
340
|
+
const kaleido = () => (ctx, w, h, t, p) => {
|
|
341
|
+
fillBg(ctx, w, h, "#07030f");
|
|
342
|
+
const cx = w / 2;
|
|
343
|
+
const cy = h / 2;
|
|
344
|
+
const R = Math.max(w, h) * 0.62;
|
|
345
|
+
const N = 12;
|
|
346
|
+
const spin = t * 0.15 + (p.x - 0.5) * 2;
|
|
347
|
+
const reach = 0.8 + (p.y - 0.5) * 0.6;
|
|
348
|
+
ctx.globalCompositeOperation = "lighter";
|
|
349
|
+
for (let i = 0; i < N; i++) {
|
|
350
|
+
ctx.save();
|
|
351
|
+
ctx.translate(cx, cy);
|
|
352
|
+
ctx.rotate(spin + (i * TAU) / N);
|
|
353
|
+
if (i % 2)
|
|
354
|
+
ctx.scale(1, -1);
|
|
355
|
+
for (let j = 0; j < 8; j++) {
|
|
356
|
+
const r = R * (0.1 + 0.7 * Math.abs(Math.sin(t * 0.5 + j * 1.3)) * reach);
|
|
357
|
+
const a = Math.sin(t * 0.7 + j * 2.1) * 0.25;
|
|
358
|
+
const x = Math.cos(a) * r;
|
|
359
|
+
const y = Math.sin(a) * r;
|
|
360
|
+
const g = ctx.createRadialGradient(x, y, 0, x, y, R * 0.2);
|
|
361
|
+
const hue = (j * 55 + t * 30) % 360;
|
|
362
|
+
g.addColorStop(0, `hsla(${hue},100%,60%,0.95)`);
|
|
363
|
+
g.addColorStop(1, `hsla(${hue},100%,50%,0)`);
|
|
364
|
+
ctx.fillStyle = g;
|
|
365
|
+
ctx.beginPath();
|
|
366
|
+
ctx.arc(x, y, R * 0.2, 0, TAU);
|
|
367
|
+
ctx.fill();
|
|
368
|
+
}
|
|
369
|
+
ctx.restore();
|
|
370
|
+
}
|
|
371
|
+
ctx.globalCompositeOperation = "source-over";
|
|
372
|
+
};
|
|
373
|
+
/** Lluvia de columnas luminosas tipo matriz. El puntero acelera las columnas cercanas. */
|
|
374
|
+
const rain = () => {
|
|
375
|
+
let cols = [];
|
|
376
|
+
let lastW = 0;
|
|
377
|
+
return (ctx, w, h, _t, p) => {
|
|
378
|
+
const cw = Math.max(6, Math.round(w / 64));
|
|
379
|
+
const n = Math.ceil(w / cw);
|
|
380
|
+
if (lastW !== w || cols.length !== n) {
|
|
381
|
+
lastW = w;
|
|
382
|
+
cols = Array.from({ length: n }, () => ({
|
|
383
|
+
y: Math.random() * h * 1.5 - h * 0.5,
|
|
384
|
+
v: 0.4 + Math.random() * 1.6,
|
|
385
|
+
len: h * (0.15 + Math.random() * 0.4),
|
|
386
|
+
}));
|
|
387
|
+
}
|
|
388
|
+
fillBg(ctx, w, h, "#000");
|
|
389
|
+
for (let i = 0; i < n; i++) {
|
|
390
|
+
const c = cols[i];
|
|
391
|
+
const dx = (i * cw) / w - p.x;
|
|
392
|
+
const near = Math.exp(-((dx * 7) ** 2)) * (p.down ? 2 : 1);
|
|
393
|
+
c.y += c.v * (h / 160) * (1 + near * 2.5);
|
|
394
|
+
if (c.y - c.len > h) {
|
|
395
|
+
c.y = -Math.random() * h * 0.3;
|
|
396
|
+
c.v = 0.4 + Math.random() * 1.6;
|
|
397
|
+
}
|
|
398
|
+
const g = ctx.createLinearGradient(0, c.y - c.len, 0, c.y);
|
|
399
|
+
g.addColorStop(0, "rgba(0,255,120,0)");
|
|
400
|
+
g.addColorStop(0.7, "rgba(0,255,120,0.9)");
|
|
401
|
+
g.addColorStop(1, "rgba(220,255,240,1)");
|
|
402
|
+
ctx.fillStyle = g;
|
|
403
|
+
ctx.fillRect(i * cw, c.y - c.len, cw - 1, c.len);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
/** Esferas luminosas con estela. El puntero las atrae. */
|
|
408
|
+
const orbs = () => {
|
|
409
|
+
const balls = Array.from({ length: 22 }, (_, i) => ({
|
|
410
|
+
x: Math.random(),
|
|
411
|
+
y: Math.random(),
|
|
412
|
+
vx: (Math.random() - 0.5) * 0.004,
|
|
413
|
+
vy: (Math.random() - 0.5) * 0.004,
|
|
414
|
+
hue: i * 23,
|
|
415
|
+
r: 0.055 + Math.random() * 0.06,
|
|
416
|
+
}));
|
|
417
|
+
let first = true;
|
|
418
|
+
return (ctx, w, h, t, p) => {
|
|
419
|
+
if (first) {
|
|
420
|
+
fillBg(ctx, w, h, "#05050f");
|
|
421
|
+
first = false;
|
|
422
|
+
}
|
|
423
|
+
ctx.globalCompositeOperation = "source-over";
|
|
424
|
+
ctx.fillStyle = "rgba(5,5,15,0.16)";
|
|
425
|
+
ctx.fillRect(0, 0, w, h);
|
|
426
|
+
ctx.globalCompositeOperation = "lighter";
|
|
427
|
+
for (const b of balls) {
|
|
428
|
+
if (p.active) {
|
|
429
|
+
const dx = p.x - b.x;
|
|
430
|
+
const dy = p.y - b.y;
|
|
431
|
+
const d = Math.hypot(dx, dy) + 0.001;
|
|
432
|
+
const f = (p.down ? -1 : 1) * 0.00005 / d;
|
|
433
|
+
b.vx += dx * f * 40;
|
|
434
|
+
b.vy += dy * f * 40;
|
|
435
|
+
}
|
|
436
|
+
b.x += b.vx;
|
|
437
|
+
b.y += b.vy;
|
|
438
|
+
if (b.x < 0 || b.x > 1)
|
|
439
|
+
b.vx *= -1;
|
|
440
|
+
if (b.y < 0 || b.y > 1)
|
|
441
|
+
b.vy *= -1;
|
|
442
|
+
b.x = Math.min(1, Math.max(0, b.x));
|
|
443
|
+
b.y = Math.min(1, Math.max(0, b.y));
|
|
444
|
+
const sp = Math.hypot(b.vx, b.vy);
|
|
445
|
+
if (sp > 0.012) {
|
|
446
|
+
b.vx *= 0.97;
|
|
447
|
+
b.vy *= 0.97;
|
|
448
|
+
}
|
|
449
|
+
const r = b.r * Math.min(w, h);
|
|
450
|
+
const g = ctx.createRadialGradient(b.x * w, b.y * h, 0, b.x * w, b.y * h, r);
|
|
451
|
+
const hue = (b.hue + t * 20) % 360;
|
|
452
|
+
g.addColorStop(0, `hsla(${hue},100%,65%,1)`);
|
|
453
|
+
g.addColorStop(1, `hsla(${hue},100%,50%,0)`);
|
|
454
|
+
ctx.fillStyle = g;
|
|
455
|
+
ctx.beginPath();
|
|
456
|
+
ctx.arc(b.x * w, b.y * h, r, 0, TAU);
|
|
457
|
+
ctx.fill();
|
|
458
|
+
}
|
|
459
|
+
ctx.globalCompositeOperation = "source-over";
|
|
460
|
+
};
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Texto del usuario en letras gigantes, deformado por una onda y por el puntero.
|
|
464
|
+
* `glow` lo dibuja en blanco con halo (mejor para braille o dither).
|
|
465
|
+
*/
|
|
466
|
+
const bigtext = (glow) => (ctx, w, h, t, p) => {
|
|
467
|
+
fillBg(ctx, w, h, glow ? "#02030a" : "#0a0616");
|
|
468
|
+
const { lines, size } = fitLines(ctx, textStore.text(), w, h);
|
|
469
|
+
ctx.font = BOLD_FONT(size);
|
|
470
|
+
ctx.textAlign = "center";
|
|
471
|
+
ctx.textBaseline = "middle";
|
|
472
|
+
if (glow) {
|
|
473
|
+
ctx.fillStyle = "#ffffff";
|
|
474
|
+
ctx.shadowColor = "#7fd6ff";
|
|
475
|
+
ctx.shadowBlur = size * 0.1;
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
const g = ctx.createLinearGradient(0, h * 0.2, w, h * 0.8);
|
|
479
|
+
g.addColorStop(0, `hsl(${(t * 30) % 360},95%,62%)`);
|
|
480
|
+
g.addColorStop(0.5, `hsl(${(t * 30 + 120) % 360},95%,58%)`);
|
|
481
|
+
g.addColorStop(1, `hsl(${(t * 30 + 240) % 360},95%,62%)`);
|
|
482
|
+
ctx.fillStyle = g;
|
|
483
|
+
}
|
|
484
|
+
const lh = size * 1.08;
|
|
485
|
+
const top = h / 2 - ((lines.length - 1) * lh) / 2;
|
|
486
|
+
const step = Math.max(3, Math.round(h / 80));
|
|
487
|
+
for (let y = 0; y < h; y += step) {
|
|
488
|
+
const bump = Math.exp(-(((y / h - p.y) * 7) ** 2)) * w * (p.down ? 0.09 : 0.05) * Math.sin(t * 7);
|
|
489
|
+
const off = Math.sin(y * 0.05 + t * 2.6) * w * 0.012 + bump;
|
|
490
|
+
ctx.save();
|
|
491
|
+
ctx.beginPath();
|
|
492
|
+
ctx.rect(0, y, w, step);
|
|
493
|
+
ctx.clip();
|
|
494
|
+
lines.forEach((l, i) => ctx.fillText(l, w / 2 + off, top + i * lh + size * 0.04));
|
|
495
|
+
ctx.restore();
|
|
496
|
+
}
|
|
497
|
+
ctx.shadowBlur = 0;
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* Arte de texto generado por asciify-engine (FIGlet de `createStudioText`, o la fuente
|
|
501
|
+
* bitmap 7×7 de `renderTextToCanvas`) usado como imagen fuente para los estilos Studio.
|
|
502
|
+
*/
|
|
503
|
+
const figlet = () => {
|
|
504
|
+
let art = null;
|
|
505
|
+
let key = "";
|
|
506
|
+
let pending = "";
|
|
507
|
+
let timer;
|
|
508
|
+
const request = (text, font) => {
|
|
509
|
+
const k = `${font}|${text}`;
|
|
510
|
+
if (k === key || k === pending)
|
|
511
|
+
return;
|
|
512
|
+
pending = k;
|
|
513
|
+
clearTimeout(timer);
|
|
514
|
+
timer = setTimeout(async () => {
|
|
515
|
+
let canvas;
|
|
516
|
+
if (font === "Bitmap") {
|
|
517
|
+
const core = await import("asciify-engine/core");
|
|
518
|
+
canvas = document.createElement("canvas");
|
|
519
|
+
core.renderTextToCanvas(canvas, text, { color: "#ffffff", bgColor: "#080808", scale: 1, fontSize: 10 });
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
const studio = await import("asciify-engine/studio");
|
|
523
|
+
const r = await studio.createStudioText(text.slice(0, 60), font, "#ffffff");
|
|
524
|
+
canvas = r.canvas;
|
|
525
|
+
}
|
|
526
|
+
if (pending === k) {
|
|
527
|
+
// El fondo #080808 de la librería se convertiría en una rejilla de puntos: se lleva a negro puro
|
|
528
|
+
const c2d = canvas.getContext("2d");
|
|
529
|
+
if (c2d && canvas.width && canvas.height) {
|
|
530
|
+
const img = c2d.getImageData(0, 0, canvas.width, canvas.height);
|
|
531
|
+
const d = img.data;
|
|
532
|
+
for (let i = 0; i < d.length; i += 4) {
|
|
533
|
+
d[i] = Math.max(0, (d[i] - 14) * 1.06);
|
|
534
|
+
d[i + 1] = Math.max(0, (d[i + 1] - 14) * 1.06);
|
|
535
|
+
d[i + 2] = Math.max(0, (d[i + 2] - 14) * 1.06);
|
|
536
|
+
}
|
|
537
|
+
c2d.putImageData(img, 0, 0);
|
|
538
|
+
}
|
|
539
|
+
art = canvas;
|
|
540
|
+
key = k;
|
|
541
|
+
}
|
|
542
|
+
}, 150);
|
|
543
|
+
};
|
|
544
|
+
return (ctx, w, h, t, p) => {
|
|
545
|
+
fillBg(ctx, w, h, "#000");
|
|
546
|
+
request(textStore.text(), textStore.get().font);
|
|
547
|
+
if (!art || !art.width || !art.height)
|
|
548
|
+
return;
|
|
549
|
+
const s = Math.min((w * 0.94) / art.width, (h * 0.9) / art.height);
|
|
550
|
+
const dw = art.width * s;
|
|
551
|
+
const dh = art.height * s;
|
|
552
|
+
ctx.imageSmoothingEnabled = false;
|
|
553
|
+
const wob = Math.sin(t * 1.6) * h * 0.012 + (p.y - 0.5) * h * 0.04;
|
|
554
|
+
ctx.drawImage(art, (w - dw) / 2 + (p.x - 0.5) * w * 0.04, (h - dh) / 2 + wob, dw, dh);
|
|
555
|
+
};
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* Texto que se estira con la velocidad del scroll: cuanto más rápido bajas, más se alarga
|
|
559
|
+
* y más copias fantasma deja detrás. En reposo vuelve a su forma.
|
|
560
|
+
*/
|
|
561
|
+
const elastic = () => (ctx, w, h, _t, p, s = scrollState) => {
|
|
562
|
+
fillBg(ctx, w, h, "#05060f");
|
|
563
|
+
const { lines, size } = fitLines(ctx, textStore.text(), w, h * 0.8);
|
|
564
|
+
const v = s.v;
|
|
565
|
+
const stretch = 1 + Math.abs(v) * 0.9;
|
|
566
|
+
ctx.font = BOLD_FONT(size);
|
|
567
|
+
ctx.textAlign = "center";
|
|
568
|
+
ctx.textBaseline = "middle";
|
|
569
|
+
const lh = size * 1.08;
|
|
570
|
+
const top = h / 2 - ((lines.length - 1) * lh) / 2;
|
|
571
|
+
const ghosts = 7;
|
|
572
|
+
for (let g = ghosts; g >= 0; g--) {
|
|
573
|
+
const off = g * v * h * 0.035;
|
|
574
|
+
const hue = (s.p * 300 + 200 + g * 8) % 360;
|
|
575
|
+
ctx.save();
|
|
576
|
+
ctx.translate(w / 2 + (p.x - 0.5) * w * 0.03, h / 2 + off);
|
|
577
|
+
ctx.scale(1, stretch);
|
|
578
|
+
ctx.translate(-w / 2, -h / 2);
|
|
579
|
+
ctx.globalAlpha = g === 0 ? 1 : 0.16;
|
|
580
|
+
ctx.fillStyle = `hsl(${hue},90%,${g === 0 ? 62 : 55}%)`;
|
|
581
|
+
lines.forEach((l, i) => ctx.fillText(l, w / 2, top + i * lh + size * 0.04));
|
|
582
|
+
ctx.restore();
|
|
583
|
+
}
|
|
584
|
+
ctx.globalAlpha = 1;
|
|
585
|
+
};
|
|
586
|
+
export const painters = {
|
|
587
|
+
...themePainters,
|
|
588
|
+
...shapePainters,
|
|
589
|
+
elastic,
|
|
590
|
+
bigtext: () => bigtext(false),
|
|
591
|
+
bigglow: () => bigtext(true),
|
|
592
|
+
figlet,
|
|
593
|
+
lava,
|
|
594
|
+
synthwave,
|
|
595
|
+
galaxy,
|
|
596
|
+
waves,
|
|
597
|
+
rings,
|
|
598
|
+
plasma,
|
|
599
|
+
torus,
|
|
600
|
+
text,
|
|
601
|
+
kaleido,
|
|
602
|
+
rain,
|
|
603
|
+
orbs,
|
|
604
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Pointer } from "./painters.js";
|
|
2
|
+
/**
|
|
3
|
+
* Sigue el puntero sobre un elemento (coordenadas normalizadas 0..1).
|
|
4
|
+
* Si no hay puntero real, se mueve sola en piloto automático para que los
|
|
5
|
+
* fondos sigan vivos en móviles o antes de tocar nada.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createPointerTracker(el: HTMLElement): {
|
|
8
|
+
pointer: Pointer;
|
|
9
|
+
/** Actualiza la posición suavizada; llamar una vez por fotograma. */
|
|
10
|
+
update(time: number): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sigue el puntero sobre un elemento (coordenadas normalizadas 0..1).
|
|
3
|
+
* Si no hay puntero real, se mueve sola en piloto automático para que los
|
|
4
|
+
* fondos sigan vivos en móviles o antes de tocar nada.
|
|
5
|
+
*/
|
|
6
|
+
export function createPointerTracker(el) {
|
|
7
|
+
const pointer = { x: 0.5, y: 0.5, down: false, active: false };
|
|
8
|
+
let tx = 0.5;
|
|
9
|
+
let ty = 0.5;
|
|
10
|
+
let inside = false;
|
|
11
|
+
const move = (e) => {
|
|
12
|
+
const r = el.getBoundingClientRect();
|
|
13
|
+
tx = (e.clientX - r.left) / r.width;
|
|
14
|
+
ty = (e.clientY - r.top) / r.height;
|
|
15
|
+
inside = true;
|
|
16
|
+
};
|
|
17
|
+
const leave = () => {
|
|
18
|
+
inside = false;
|
|
19
|
+
pointer.down = false;
|
|
20
|
+
};
|
|
21
|
+
const down = (e) => {
|
|
22
|
+
move(e);
|
|
23
|
+
pointer.down = true;
|
|
24
|
+
};
|
|
25
|
+
const up = () => {
|
|
26
|
+
pointer.down = false;
|
|
27
|
+
};
|
|
28
|
+
el.addEventListener("pointermove", move);
|
|
29
|
+
el.addEventListener("pointerdown", down);
|
|
30
|
+
el.addEventListener("pointerup", up);
|
|
31
|
+
el.addEventListener("pointerleave", leave);
|
|
32
|
+
el.addEventListener("pointercancel", leave);
|
|
33
|
+
return {
|
|
34
|
+
pointer,
|
|
35
|
+
/** Actualiza la posición suavizada; llamar una vez por fotograma. */
|
|
36
|
+
update(time) {
|
|
37
|
+
pointer.active = inside;
|
|
38
|
+
if (!inside) {
|
|
39
|
+
tx = 0.5 + Math.sin(time * 0.37) * 0.32;
|
|
40
|
+
ty = 0.5 + Math.sin(time * 0.53 + 1.3) * 0.28;
|
|
41
|
+
}
|
|
42
|
+
const k = inside ? 0.3 : 0.05;
|
|
43
|
+
pointer.x += (tx - pointer.x) * k;
|
|
44
|
+
pointer.y += (ty - pointer.y) * k;
|
|
45
|
+
},
|
|
46
|
+
destroy() {
|
|
47
|
+
el.removeEventListener("pointermove", move);
|
|
48
|
+
el.removeEventListener("pointerdown", down);
|
|
49
|
+
el.removeEventListener("pointerup", up);
|
|
50
|
+
el.removeEventListener("pointerleave", leave);
|
|
51
|
+
el.removeEventListener("pointercancel", leave);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|