mirror of
https://github.com/Dasemu/motion-graphics-abstraction.git
synced 2026-11-26 15:26:15 +00:00
69 lines
17 KiB
HTML
69 lines
17 KiB
HTML
<!doctype html>
|
|
<html lang="es"><head><meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>Logo animation</title>
|
|
<style>
|
|
html,body{margin:0;height:100%;background:#111;overflow:hidden;font-family:system-ui,sans-serif}
|
|
#wrap{position:absolute;inset:0 0 56px 0;overflow:hidden}
|
|
#stage{position:absolute;left:0;top:0;width:1920px;height:1080px;overflow:hidden;transform-origin:0 0}
|
|
.scene{position:absolute;inset:0;overflow:hidden}
|
|
#bar{position:absolute;left:0;right:0;bottom:0;height:56px;display:flex;align-items:center;gap:14px;padding:0 16px;box-sizing:border-box;color:#eee;background:#1b1b1b}
|
|
#bar button{background:#333;color:#eee;border:0;border-radius:8px;padding:8px 14px;font-size:15px;cursor:pointer}
|
|
#seek{flex:1}
|
|
#time{font-variant-numeric:tabular-nums;min-width:96px;text-align:right;font-size:14px}
|
|
#stage { --ground:#FBF6EC; --main:#DD0000; --second:#2B1414; --accent:#F7CF00; color:var(--second); font-family:var(--sans, system-ui, sans-serif) }
|
|
.ground { position:absolute; inset:0; background:var(--ground) }
|
|
.words { position:absolute; margin:0; display:flex; flex-direction:column; gap:24px } .words > * { margin:0 }
|
|
.line { font-family:var(--display, var(--sans, system-ui, sans-serif)); font-size:84px; line-height:1.05; font-weight:700 } .sub { font-size:36px }
|
|
.art { position:absolute; overflow:visible }
|
|
.lg-red { fill:var(--main); fill-rule:evenodd }
|
|
.lg-yel { fill:var(--accent) }
|
|
.lg-dr { fill:var(--main) }
|
|
.lg-dy { fill:var(--accent); stroke:color-mix(in srgb, var(--second) 35%, transparent); stroke-width:1.5 }
|
|
.lg-spark { fill:none; stroke:var(--accent); stroke-width:9; stroke-linecap:round }
|
|
</style></head><body>
|
|
<div id="wrap"><div id="stage"></div></div>
|
|
<div id="bar"><button id="pp">Pause</button><input id="seek" type="range" min="0" max="1000" value="0"><span id="time">0.00 / 5.00 s</span></div>
|
|
<script>
|
|
const MODS = {"logo.json": "{\"w\":963,\"h\":1193,\"red\":[\"M421 0L417 10L414 25L413 56L410 69L403 81L382 102L376 106L373 106L364 95L359 109L355 110L353 108L353 96L357 74L353 52L347 52L341 60L333 83L332 143L325 163L315 173L303 180L290 182L288 180L288 165L283 166L261 192L233 217L226 232L204 248L183 259L177 260L162 242L159 243L158 267L161 273L161 278L154 299L163 314L176 324L191 327L194 324L193 313L197 309L203 309L207 311L213 311L215 309L213 296L219 290L269 272L272 275L257 291L197 347L174 363L163 367L147 365L141 359L140 352L143 342L142 331L140 331L132 339L123 341L116 335L108 321L102 314L93 312L91 314L91 317L97 324L99 329L102 358L107 373L111 379L120 387L130 392L141 392L160 388L184 376L206 360L240 329L270 310L300 295L318 294L324 299L321 307L313 315L301 316L300 320L302 325L300 327L295 327L288 324L286 327L286 340L283 343L267 343L267 350L275 363L286 375L296 373L300 378L301 388L304 389L307 387L313 373L319 366L323 367L331 376L334 374L334 361L328 349L326 340L328 335L344 318L355 303L386 276L401 269L416 254L425 252L440 259L443 262L451 280L459 291L460 305L464 315L464 340L473 356L469 371L469 388L473 397L481 407L482 419L486 429L486 435L479 442L465 449L456 449L448 446L432 436L423 428L422 416L418 405L411 397L401 391L385 391L376 393L376 396L386 409L386 412L384 414L381 414L370 404L340 404L333 407L331 412L331 421L335 422L342 417L348 418L352 422L356 438L371 447L371 452L363 459L351 477L351 482L353 484L368 477L373 478L381 485L396 485L422 479L428 479L440 484L446 489L448 493L449 511L456 515L467 517L473 525L476 525L479 522L478 489L488 486L495 477L499 479L501 483L500 495L486 515L486 519L488 521L495 520L502 516L505 516L507 518L500 553L500 564L496 568L467 566L450 556L439 552L433 544L431 532L432 523L435 518L435 510L425 502L413 497L409 499L409 501L416 508L416 512L411 519L411 525L413 528L412 537L410 539L407 539L395 532L392 532L376 541L371 546L372 552L379 553L387 559L398 560L405 564L405 566L397 573L389 585L389 592L391 595L398 592L409 594L419 584L430 584L433 588L433 602L428 606L429 610L435 610L448 604L450 602L450 594L453 589L456 589L469 597L478 606L481 612L481 619L477 623L468 626L471 628L483 628L485 632L476 642L467 657L469 679L477 694L476 701L472 703L458 694L449 691L449 693L456 700L456 713L449 725L440 734L428 739L423 743L415 740L404 740L396 731L382 709L382 701L376 671L385 662L400 652L405 651L411 647L413 627L410 621L407 618L405 619L406 628L403 632L388 632L381 641L372 643L369 639L370 628L366 624L347 615L339 613L336 614L337 619L341 623L340 637L347 649L347 654L344 656L339 652L325 652L312 656L310 660L319 667L322 675L325 678L334 678L344 687L344 692L334 702L324 702L323 705L330 713L336 716L342 716L351 711L354 711L357 716L356 732L352 746L346 754L339 752L330 744L327 745L329 752L341 767L342 773L326 790L326 797L321 807L309 818L301 819L294 812L283 807L279 802L278 796L285 773L283 754L284 746L290 738L309 726L309 714L312 706L312 701L306 690L299 682L296 683L298 690L292 695L287 694L283 690L281 685L277 682L272 681L270 683L270 689L262 698L262 703L265 711L265 721L262 727L252 739L243 746L240 758L237 761L230 761L228 764L229 768L233 772L252 768L258 775L256 808L240 835L241 837L248 838L257 847L267 865L269 877L266 880L258 880L244 875L243 878L249 883L264 889L293 890L314 883L329 883L340 897L347 916L347 949L338 972L329 980L312 983L302 988L295 987L285 981L276 979L268 975L260 967L251 951L246 932L237 908L235 892L230 880L225 873L225 847L222 835L221 813L200 764L191 753L184 741L173 730L164 724L149 718L138 716L131 718L119 728L107 748L105 748L100 743L100 740L103 737L96 734L85 733L83 731L83 728L72 732L60 742L57 741L70 710L70 707L68 707L66 704L70 693L73 676L70 670L71 658L74 656L100 674L111 674L111 671L102 656L91 622L86 594L85 565L83 557L79 552L75 553L71 558L51 596L39 603L30 616L12 632L0 646L0 654L2 655L14 654L30 650L37 656L38 664L33 682L33 690L36 703L32 714L30 734L25 749L28 768L28 782L35 790L55 806L54 814L58 818L82 832L80 834L80 837L95 837L110 833L112 835L111 836L114 837L121 828L126 815L128 813L131 813L133 810L135 789L140 782L148 784L158 794L157 798L155 796L153 797L161 810L171 821L175 830L176 849L174 851L169 842L167 842L166 845L169 863L175 879L185 918L184 924L177 918L171 906L170 908L181 940L190 957L192 971L195 978L211 999L221 1021L245 1044L265 1058L262 1061L255 1061L255 1063L273 1071L300 1071L348 1054L371 1040L374 1040L376 1042L376 1047L371 1055L377 1051L390 1034L399 1016L411 980L432 957L443 950L448 949L450 951L450 957L444 976L431 997L414 1015L418 1015L445 1005L461 996L488 972L506 948L517 939L533 936L535 938L535 941L525 955L505 973L497 977L497 979L511 976L535 964L557 946L575 917L586 905L588 905L588 913L579 932L579 934L581 934L597 911L611 883L629 858L633 849L638 829L656 791L667 783L675 781L680 786L687 803L685 817L672 838L640 873L635 882L634 888L638 887L655 870L669 867L680 871L690 882L695 897L695 906L692 921L688 929L676 945L617 999L595 1016L595 1019L598 1021L608 1021L622 1017L632 1009L671 992L690 992L705 996L721 1005L730 1014L735 1028L736 1039L731 1073L726 1090L702 1136L683 1180L682 1192L684 1192L690 1179L759 1109L808 1042L859 961L868 942L875 916L887 894L890 885L901 830L901 791L905 785L914 787L925 797L933 811L938 827L941 847L941 873L934 928L934 935L936 936L938 928L948 906L959 865L960 856L962 855L962 765L960 764L957 697L943 635L929 584L926 562L919 535L875 402L851 352L842 343L835 339L822 339L816 334L807 331L796 332L779 338L765 339L749 345L744 357L743 376L747 380L755 381L762 390L764 409L759 427L750 440L739 450L722 445L708 433L707 436L710 441L708 444L700 439L676 415L672 409L672 406L676 405L689 410L695 416L698 416L698 413L693 404L677 386L680 374L684 371L692 371L693 369L687 363L655 355L641 348L620 340L615 335L610 327L610 323L615 318L628 318L628 316L618 308L600 305L580 291L576 286L573 277L574 270L577 267L587 267L591 269L590 264L584 257L571 247L562 242L540 234L537 231L539 228L548 228L551 230L551 225L544 219L516 206L509 199L508 193L514 187L522 183L531 184L531 181L528 178L520 175L477 175L474 173L474 170L484 163L481 160L454 164L450 160L451 151L455 139L454 133L451 133L432 158L429 159L426 156L426 133L444 111L450 101L450 98L436 101L427 100L427 96L437 78L439 71L440 46L429 9L424 0Z\",\"M80 768L88 769L93 775L94 783L87 790L81 788L75 780L77 772Z\",\"M284 188L285 198L287 202L287 210L284 216L274 223L263 224L257 227L254 223L261 209L279 191Z\"],\"yel\":[\"M259 454L252 452L245 452L224 462L214 473L212 470L210 462L208 460L205 460L204 461L204 468L214 487L212 489L211 488L191 488L181 492L174 499L171 505L168 518L169 543L176 558L184 571L193 581L201 586L213 589L230 587L240 591L247 590L260 578L272 558L277 545L277 517L278 513L270 501L261 492L254 488L243 485L222 485L217 480L220 472L223 469L227 469L234 472L244 472L261 476L264 479L271 493L273 495L279 497L280 495L275 486L273 467L265 457Z\",\"M284 189L279 192L262 209L256 219L255 224L257 226L263 223L274 222L280 219L283 216L286 210L286 202L284 198Z\"]}", "shared.js": "window.LOGO = {\n build(kit, id) {\n const { seg, eio } = kit;\n const d = kit.json('logo.json');\n const all = d.red.join('');\n let sp = '';\n for (let i = 0; i < 6; i++) {\n const a = (-170 + i * 32) * Math.PI / 180, c = Math.cos(a), s = Math.sin(a);\n sp += '<path class=\"lg-spark\" pathLength=\"1\" d=\"M' + (225 + c * 100).toFixed(1) + ' ' + (520 + s * 100).toFixed(1) + 'L' + (225 + c * 150).toFixed(1) + ' ' + (520 + s * 150).toFixed(1) + '\"/>';\n }\n const svg = kit.h('<svg class=\"art\" viewBox=\"0 0 963 1193\" style=\"left:597px;top:90px;width:726px;height:900px\">' +\n '<defs><clipPath id=\"' + id + '-c\"><circle class=\"lg-clip\" cx=\"480\" cy=\"700\" r=\"0\"/><\/clipPath><\/defs>' +\n '<g class=\"lg-g\">' +\n '<path class=\"lg-red\" clip-path=\"url(#' + id + '-c)\" d=\"' + all + '\"/>' +\n '<g class=\"lg-ap\"><path class=\"lg-yel\" d=\"' + d.yel[0] + '\"/><\/g>' +\n '<g class=\"lg-ey\"><path class=\"lg-yel\" d=\"' + d.yel[1] + '\"/><\/g>' +\n '<g class=\"lg-sp\">' + sp + '<\/g><g class=\"lg-dots\"><\/g><\/g><\/svg>');\n kit.stage.append(svg);\n const q = s => svg.querySelector(s);\n const L = { svg, g: q('.lg-g'), clip: q('.lg-clip'), ap: q('.lg-ap'), ey: q('.lg-ey'), sp: [...svg.querySelectorAll('.lg-spark')], P: [] };\n L.g.style.transformOrigin = '481px 596px';\n L.ap.style.transformOrigin = '225px 590px';\n L.ey.style.transformOrigin = '270px 207px';\n const rnd = kit.rng(11), dots = q('.lg-dots');\n const src = [[q('.lg-red'), 240, 0], [q('.lg-ap path'), 64, 1], [q('.lg-ey path'), 12, 2]];\n for (const [el, n, g] of src) {\n const len = el.getTotalLength();\n for (let i = 0; i < n; i++) {\n const pt = el.getPointAtLength(len * (i + rnd() * 0.6) / n);\n const sx = -700 + rnd() * 2350, sy = -90 + rnd() * 1370;\n const dx = pt.x - sx, dy = pt.y - sy, m = Math.hypot(dx, dy) || 1;\n const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\n c.setAttribute('class', g === 0 && rnd() < 0.55 ? 'lg-dr' : 'lg-dy');\n dots.append(c);\n L.P.push({ el: c, g, tx: pt.x, ty: pt.y, sx, sy, px: -dy / m, py: dx / m, amp: (rnd() - 0.5) * 260, dl: rnd() * 0.7, r: 4.5 + rnd() * 3.5, ph: rnd() * 6.28, dist: Math.hypot(pt.x - 480, pt.y - 700) });\n }\n }\n L.seg = seg; L.eio = eio;\n return L;\n },\n set(L, s) {\n const n = (v, d) => (v === undefined ? d : v);\n L.g.style.transform = 'translate(0px,' + n(s.dy, 0) + 'px) scale(' + n(s.scale, 1) + ')';\n L.clip.setAttribute('r', n(s.flood, 0));\n L.ap.style.opacity = n(s.apOp, 0);\n L.ap.style.transform = 'translate(0px,' + n(s.apY, 0) + 'px) scale(' + n(s.apSx, 1) + ',' + n(s.apSy, 1) + ')';\n L.ey.style.opacity = n(s.eyOp, 0);\n L.ey.style.transform = 'scale(' + Math.max(0.001, n(s.eyS, 1)) + ')';\n const sk = n(s.spark, -1);\n L.sp.forEach((e, i) => {\n const k = L.seg(sk, i * 0.05, 0.6 + i * 0.05), a = L.eio(k), tail = L.eio(L.seg(k, 0.45, 1));\n e.style.strokeDasharray = Math.max(0, a - tail) + ' 1';\n e.style.strokeDashoffset = -tail;\n e.style.opacity = sk < 0 || a - tail < 0.01 ? 0 : 1;\n });\n const pt = n(s.pt, 99), T = n(s.T, 0), kill = n(s.kill, -1), apKill = n(s.apKill, 0);\n for (const p of L.P) {\n const u = L.eio(L.seg(pt, p.dl, p.dl + 1.1)), w = Math.sin(Math.PI * u) * p.amp;\n const x = p.sx + (p.tx - p.sx) * u + p.px * w + Math.sin(T * 5 + p.ph) * 1.8 * u;\n const y = p.sy + (p.ty - p.sy) * u + p.py * w + Math.cos(T * 4 + p.ph) * 1.8 * u;\n let sc = 1;\n if (p.g === 0 && kill >= 0) sc = 1 - L.seg(kill, p.dist - 40, p.dist + 10);\n if (p.g > 0) sc = 1 - apKill;\n p.el.setAttribute('cx', x.toFixed(1)); p.el.setAttribute('cy', y.toFixed(1));\n p.el.setAttribute('r', (p.r * sc * (1.3 - 0.3 * u)).toFixed(2));\n p.el.style.opacity = sc > 0.01 ? L.seg(pt, p.dl, p.dl + 0.12) : 0;\n }\n },\n};", "scene-trace.js": "const { lerp, seg, eo } = kit;\nkit.scene('trace', {\n init(kit) {\n kit.stage.append(kit.h('<div class=\"ground\"><\/div>'));\n this.L = window.LOGO.build(kit, 'trace');\n },\n render(t, kit) {\n window.LOGO.set(this.L, {\n pt: t + 0.3,\n T: kit.start + t,\n scale: lerp(0.97, 1, eo(seg(t, 0, 2))),\n });\n },\n});", "scene-fill.js": "const { seg, eio, eob, lerp } = kit;\nkit.scene('fill', {\n init(kit) {\n kit.stage.append(kit.h('<div class=\"ground\"><\/div>'));\n this.L = window.LOGO.build(kit, 'fill');\n },\n render(t, kit) {\n const r = lerp(0, 900, eio(seg(t, 0.15, 1.15)));\n const pop = eob(seg(t, 0.9, 1.3), 1.7);\n const bump = Math.sin(Math.PI * seg(t, 0.95, 1.5));\n window.LOGO.set(this.L, {\n pt: t + 2.3,\n T: kit.start + t,\n flood: r,\n kill: r,\n apKill: seg(t, 0.95, 1.25),\n eyOp: seg(t, 0.75, 0.85),\n eyS: eob(seg(t, 0.75, 1.1), 1.8),\n apOp: seg(t, 0.9, 1.0),\n apSx: lerp(0.6, 1, pop),\n apSy: lerp(0.6, 1, pop),\n scale: 1 + 0.012 * bump,\n });\n },\n});", "scene-hold.js": "const { seg, eo, lerp } = kit;\nkit.scene('hold', {\n init(kit) {\n kit.stage.append(kit.h('<div class=\"ground\"><\/div>'));\n this.L = window.LOGO.build(kit, 'hold');\n },\n render(t, kit) {\n const b = Math.sin(2 * Math.PI * t / 2.4);\n window.LOGO.set(this.L, {\n pt: 99,\n T: kit.start + t,\n flood: 900,\n kill: 900,\n apKill: 1,\n eyOp: 1,\n eyS: 1 + 0.03 * b,\n apOp: 1,\n apSx: 1 - 0.008 * b,\n apSy: 1 + 0.012 * b,\n spark: seg(t, 0.05, 1.1),\n scale: lerp(1, 1.03, eo(seg(t, 0, 1.2))),\n });\n },\n});"};
|
|
const SCENES = [{id:'trace',dur:2},{id:'fill',dur:1.8},{id:'hold',dur:1.2}];
|
|
const DURATION = SCENES.reduce((a,s)=>a+s.dur,0);
|
|
const W=1920,H=1080,stage=document.getElementById('stage');
|
|
/* helpers (same math as the original runtime) */
|
|
const clamp01=x=>x<0?0:x>1?1:x, seg=(t,a,b)=>clamp01((t-a)/(b-a)), lerp=(a,b,p)=>a+(b-a)*p;
|
|
const eo=x=>1-Math.pow(1-clamp01(x),3);
|
|
const eio=x=>{x=clamp01(x);return x<.5?4*x*x*x:1-Math.pow(-2*x+2,3)/2};
|
|
const eob=(x,c1=1.4)=>{x=clamp01(x);const c3=c1+1;return 1+c3*Math.pow(x-1,3)+c1*Math.pow(x-1,2)};
|
|
function rng(seed){let s=seed>>>0;return()=>{s=(s*1664525+1013904223)>>>0;return s/4294967296}}
|
|
function h(html){const t=document.createElement('template');t.innerHTML=String(html).trim();return t.content.firstElementChild}
|
|
const base={W,H,seg,lerp,eo,eio,eob,rng,clamp01,h,json:n=>JSON.parse(MODS[n])};
|
|
/* shared.js defines window.LOGO */
|
|
new Function('kit',MODS['shared.js']).call(window,Object.assign({},base,{stage}));
|
|
/* scenes */
|
|
let start=0;const defs={};
|
|
SCENES.forEach(s=>{
|
|
const box=document.createElement('div');box.className='scene';stage.appendChild(box);
|
|
const kit=Object.assign({},base,{stage:box,start,dur:s.dur,scene:(id,def)=>{defs[id]=def}});
|
|
new Function('kit',MODS['scene-'+s.id+'.js'])(kit);
|
|
defs[s.id].init(kit);defs[s.id].box=box;defs[s.id].kit=kit;defs[s.id].t0=start;
|
|
start+=s.dur;
|
|
});
|
|
function render(t){
|
|
t=Math.max(0,Math.min(DURATION,t));
|
|
let i=0,acc=0;for(;i<SCENES.length-1&&t>=acc+SCENES[i].dur;i++)acc+=SCENES[i].dur;
|
|
SCENES.forEach((s,k)=>{defs[s.id].box.style.display=k===i?'':'none'});
|
|
const d=defs[SCENES[i].id];d.render(t-acc,d.kit);
|
|
}
|
|
/* fit + transport */
|
|
function fit(){const w=document.getElementById('wrap'),k=Math.min(w.clientWidth/W,w.clientHeight/H);
|
|
stage.style.transform='scale('+k+')';stage.style.left=((w.clientWidth-W*k)/2)+'px';stage.style.top=((w.clientHeight-H*k)/2)+'px'}
|
|
addEventListener('resize',fit);fit();
|
|
const pp=document.getElementById('pp'),seek=document.getElementById('seek'),tl=document.getElementById('time');
|
|
let playing=true,t=0,last=performance.now();
|
|
function show(){render(t);seek.value=Math.round(t/DURATION*1000);tl.textContent=t.toFixed(2)+' / '+DURATION.toFixed(2)+' s'}
|
|
function loop(now){if(playing){t+=(now-last)/1000;if(t>=DURATION)t=0}last=now;show();requestAnimationFrame(loop)}
|
|
pp.onclick=()=>{playing=!playing;pp.textContent=playing?'Pause':'Play'};
|
|
seek.oninput=()=>{t=seek.value/1000*DURATION;playing=false;pp.textContent='Play'};
|
|
addEventListener('keydown',e=>{if(e.code==='Space'){e.preventDefault();pp.click()}});
|
|
requestAnimationFrame(loop);
|
|
</script></body></html> |