Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,246 @@
|
||||
/* Cinematic image layer and lightweight motion effects. */
|
||||
.token-factory-scene {
|
||||
--factory-parallax-x: 0px;
|
||||
--factory-parallax-y: 0px;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: -1;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
background: #020611;
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
.token-factory-scene__image {
|
||||
position: absolute;
|
||||
inset: -3.5%;
|
||||
background-image: url('/assets/token-factory-cinematic-v2-web.webp');
|
||||
background-position: center center;
|
||||
background-size: cover;
|
||||
filter: saturate(1.08) contrast(1.08) brightness(0.88);
|
||||
transform: translate3d(
|
||||
var(--factory-parallax-x),
|
||||
var(--factory-parallax-y),
|
||||
0
|
||||
)
|
||||
scale(1.055);
|
||||
animation: factory-camera-breathe 18s ease-in-out infinite alternate;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.token-factory-scene__grade {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
radial-gradient(
|
||||
ellipse 28% 62% at 50% 49%,
|
||||
rgba(0, 4, 12, 0.62) 0%,
|
||||
rgba(1, 7, 18, 0.36) 48%,
|
||||
transparent 100%
|
||||
),
|
||||
linear-gradient(
|
||||
90deg,
|
||||
rgba(1, 5, 13, 0.06),
|
||||
transparent 30%,
|
||||
transparent 68%,
|
||||
rgba(0, 4, 12, 0.18)
|
||||
),
|
||||
linear-gradient(
|
||||
180deg,
|
||||
rgba(1, 5, 14, 0.2),
|
||||
transparent 38%,
|
||||
rgba(0, 3, 10, 0.4)
|
||||
);
|
||||
mix-blend-mode: multiply;
|
||||
}
|
||||
|
||||
.token-factory-scene__beam {
|
||||
position: absolute;
|
||||
width: 52vw;
|
||||
height: 9vh;
|
||||
top: 59%;
|
||||
left: -18vw;
|
||||
opacity: 0.42;
|
||||
filter: blur(16px);
|
||||
transform: rotate(-3deg);
|
||||
animation: factory-energy-sweep 8.5s cubic-bezier(0.42, 0, 0.2, 1) infinite;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(255, 184, 78, 0.8),
|
||||
rgba(255, 238, 191, 0.92),
|
||||
transparent
|
||||
);
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
|
||||
.token-factory-scene__beam--cool {
|
||||
top: 66%;
|
||||
left: -32vw;
|
||||
width: 68vw;
|
||||
height: 7vh;
|
||||
opacity: 0.38;
|
||||
animation-delay: -4.2s;
|
||||
animation-duration: 10.5s;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(28, 178, 255, 0.8),
|
||||
rgba(124, 239, 255, 0.92),
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
.token-factory-scene__haze {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
radial-gradient(
|
||||
circle at 50% 46%,
|
||||
rgba(63, 196, 255, 0.15),
|
||||
transparent 20%
|
||||
),
|
||||
radial-gradient(
|
||||
circle at 12% 48%,
|
||||
rgba(255, 181, 78, 0.1),
|
||||
transparent 26%
|
||||
),
|
||||
linear-gradient(
|
||||
112deg,
|
||||
transparent 42%,
|
||||
rgba(93, 211, 255, 0.06) 51%,
|
||||
transparent 59%
|
||||
);
|
||||
animation: factory-haze-pulse 7s ease-in-out infinite alternate;
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
|
||||
.token-factory-scene__particles {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
|
||||
.token-factory-scene__vignette {
|
||||
position: absolute;
|
||||
inset: -1px;
|
||||
box-shadow:
|
||||
inset 0 0 17vw 3vw rgba(0, 2, 8, 0.72),
|
||||
inset 0 -16vh 18vh rgba(0, 3, 10, 0.52);
|
||||
}
|
||||
|
||||
.token-factory-scene__grain {
|
||||
position: absolute;
|
||||
inset: -50%;
|
||||
opacity: 0.055;
|
||||
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.85'/%3E%3C/svg%3E");
|
||||
animation: factory-film-grain 0.35s steps(2) infinite;
|
||||
mix-blend-mode: soft-light;
|
||||
}
|
||||
|
||||
@keyframes factory-camera-breathe {
|
||||
from {
|
||||
transform: translate3d(
|
||||
var(--factory-parallax-x),
|
||||
var(--factory-parallax-y),
|
||||
0
|
||||
)
|
||||
scale(1.055);
|
||||
}
|
||||
to {
|
||||
transform: translate3d(
|
||||
var(--factory-parallax-x),
|
||||
var(--factory-parallax-y),
|
||||
0
|
||||
)
|
||||
scale(1.075);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes factory-energy-sweep {
|
||||
0% {
|
||||
transform: translate3d(-8vw, 0, 0) rotate(-3deg) scaleX(0.7);
|
||||
opacity: 0;
|
||||
}
|
||||
18% {
|
||||
opacity: 0.42;
|
||||
}
|
||||
72% {
|
||||
opacity: 0.3;
|
||||
}
|
||||
100% {
|
||||
transform: translate3d(148vw, -3vh, 0) rotate(-3deg) scaleX(1.1);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes factory-haze-pulse {
|
||||
from {
|
||||
opacity: 0.62;
|
||||
transform: scale(1);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: scale(1.035);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes factory-film-grain {
|
||||
0% {
|
||||
transform: translate3d(-2%, 1%, 0);
|
||||
}
|
||||
25% {
|
||||
transform: translate3d(1%, -2%, 0);
|
||||
}
|
||||
50% {
|
||||
transform: translate3d(2%, 2%, 0);
|
||||
}
|
||||
75% {
|
||||
transform: translate3d(-1%, -1%, 0);
|
||||
}
|
||||
100% {
|
||||
transform: translate3d(0, 2%, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.token-factory-scene__image {
|
||||
inset: -2%;
|
||||
background-position: 51% center;
|
||||
transform: scale(1.04);
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.token-factory-scene__grade {
|
||||
background:
|
||||
radial-gradient(
|
||||
ellipse 72% 50% at 50% 48%,
|
||||
rgba(1, 5, 14, 0.58),
|
||||
transparent 100%
|
||||
),
|
||||
linear-gradient(
|
||||
180deg,
|
||||
rgba(1, 5, 14, 0.24),
|
||||
transparent 35%,
|
||||
rgba(0, 3, 10, 0.5)
|
||||
);
|
||||
}
|
||||
|
||||
.token-factory-scene__beam {
|
||||
opacity: 0.25;
|
||||
}
|
||||
.token-factory-scene__grain {
|
||||
opacity: 0.035;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.token-factory-scene__image,
|
||||
.token-factory-scene__beam,
|
||||
.token-factory-scene__haze,
|
||||
.token-factory-scene__grain {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import './CinematicTokenFactory.css';
|
||||
|
||||
const mulberry32 = (seed) => {
|
||||
let value = seed >>> 0;
|
||||
return () => {
|
||||
value += 0x6d2b79f5;
|
||||
let result = value;
|
||||
result = Math.imul(result ^ (result >>> 15), result | 1);
|
||||
result ^= result + Math.imul(result ^ (result >>> 7), result | 61);
|
||||
return ((result ^ (result >>> 14)) >>> 0) / 4294967296;
|
||||
};
|
||||
};
|
||||
|
||||
const CinematicTokenFactory = () => {
|
||||
const sceneRef = useRef(null);
|
||||
const canvasRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const scene = sceneRef.current;
|
||||
const canvas = canvasRef.current;
|
||||
if (!scene || !canvas) return undefined;
|
||||
|
||||
const context = canvas.getContext('2d');
|
||||
const motionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||
let reducedMotion = motionQuery.matches;
|
||||
const random = mulberry32(0x746f6b65);
|
||||
const particles = Array.from({ length: 48 }, (_, index) => ({
|
||||
x: random(),
|
||||
y: random(),
|
||||
depth: 0.35 + random() * 0.9,
|
||||
radius: index % 8 === 0 ? 3 + random() * 2.4 : 0.6 + random() * 1.5,
|
||||
speed: 0.000018 + random() * 0.000035,
|
||||
phase: random() * Math.PI * 2,
|
||||
token: index % 8 === 0,
|
||||
}));
|
||||
|
||||
let width = 0;
|
||||
let height = 0;
|
||||
let dpr = 1;
|
||||
let frameId = 0;
|
||||
let visible = !document.hidden;
|
||||
let pointerX = 0;
|
||||
let pointerY = 0;
|
||||
let smoothX = 0;
|
||||
let smoothY = 0;
|
||||
let lastFrameTime = 0;
|
||||
|
||||
const resize = () => {
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
dpr = Math.min(window.devicePixelRatio || 1, 1.5);
|
||||
canvas.width = Math.round(width * dpr);
|
||||
canvas.height = Math.round(height * dpr);
|
||||
canvas.style.width = `${width}px`;
|
||||
canvas.style.height = `${height}px`;
|
||||
context.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||
};
|
||||
|
||||
const onPointerMove = (event) => {
|
||||
pointerX = event.clientX / Math.max(width, 1) - 0.5;
|
||||
pointerY = event.clientY / Math.max(height, 1) - 0.5;
|
||||
};
|
||||
|
||||
const drawEnergyStream = (time, y, color, speed, amplitude) => {
|
||||
context.save();
|
||||
context.globalCompositeOperation = 'screen';
|
||||
context.lineWidth = 1.15;
|
||||
context.strokeStyle = color;
|
||||
context.shadowColor = color;
|
||||
context.shadowBlur = 10;
|
||||
context.beginPath();
|
||||
for (let x = -40; x <= width + 40; x += 18) {
|
||||
const progress = x / Math.max(width, 1);
|
||||
const wave = Math.sin(progress * 8 + time * speed) * amplitude;
|
||||
const perspective = (progress - 0.52) ** 2 * height * 0.08;
|
||||
const py = height * y + wave + perspective;
|
||||
if (x === -40) context.moveTo(x, py);
|
||||
else context.lineTo(x, py);
|
||||
}
|
||||
context.stroke();
|
||||
|
||||
for (let i = 0; i < 6; i += 1) {
|
||||
const progress = (time * speed * 0.13 + i / 6) % 1;
|
||||
const x = progress * width;
|
||||
const wave = Math.sin(progress * 8 + time * speed) * amplitude;
|
||||
const py = height * y + wave + (progress - 0.52) ** 2 * height * 0.08;
|
||||
const glow = context.createRadialGradient(x, py, 0, x, py, 13);
|
||||
glow.addColorStop(0, 'rgba(255,255,255,.95)');
|
||||
glow.addColorStop(0.25, color);
|
||||
glow.addColorStop(1, 'rgba(0,0,0,0)');
|
||||
context.fillStyle = glow;
|
||||
context.beginPath();
|
||||
context.arc(x, py, 13, 0, Math.PI * 2);
|
||||
context.fill();
|
||||
}
|
||||
context.restore();
|
||||
};
|
||||
|
||||
const drawParticle = (particle, time, deltaMs) => {
|
||||
if (!reducedMotion) {
|
||||
particle.x += particle.speed * particle.depth * deltaMs;
|
||||
particle.y +=
|
||||
Math.sin(time * 0.00045 + particle.phase) *
|
||||
0.000025 *
|
||||
(deltaMs / 16.67);
|
||||
if (particle.x > 1.08) particle.x = -0.08;
|
||||
}
|
||||
|
||||
const x = particle.x * width + smoothX * 24 * particle.depth;
|
||||
const y = particle.y * height + smoothY * 14 * particle.depth;
|
||||
const pulse = 0.65 + Math.sin(time * 0.0012 + particle.phase) * 0.35;
|
||||
context.save();
|
||||
context.globalCompositeOperation = 'screen';
|
||||
|
||||
if (particle.token) {
|
||||
const radius = particle.radius * (0.85 + pulse * 0.2);
|
||||
context.translate(x, y);
|
||||
context.rotate(Math.sin(time * 0.00035 + particle.phase) * 0.35);
|
||||
context.shadowColor = '#ffc861';
|
||||
context.shadowBlur = 14;
|
||||
context.strokeStyle = `rgba(255, 202, 98, ${0.45 + pulse * 0.4})`;
|
||||
context.lineWidth = 1.1;
|
||||
context.beginPath();
|
||||
context.arc(0, 0, radius * 1.65, 0, Math.PI * 2);
|
||||
context.stroke();
|
||||
context.beginPath();
|
||||
context.moveTo(-radius * 0.65, -radius * 0.15);
|
||||
context.lineTo(radius * 0.65, -radius * 0.15);
|
||||
context.moveTo(-radius * 0.65, radius * 0.35);
|
||||
context.lineTo(radius * 0.65, radius * 0.35);
|
||||
context.stroke();
|
||||
} else {
|
||||
context.shadowColor = '#72e8ff';
|
||||
context.shadowBlur = 9;
|
||||
context.fillStyle = `rgba(125, 231, 255, ${0.18 + pulse * 0.5})`;
|
||||
context.beginPath();
|
||||
context.arc(x, y, particle.radius * pulse, 0, Math.PI * 2);
|
||||
context.fill();
|
||||
}
|
||||
context.restore();
|
||||
};
|
||||
|
||||
const render = (time = 0) => {
|
||||
const deltaMs = lastFrameTime
|
||||
? Math.min(Math.max(time - lastFrameTime, 0), 50)
|
||||
: 16.67;
|
||||
lastFrameTime = time;
|
||||
context.clearRect(0, 0, width, height);
|
||||
smoothX += (pointerX - smoothX) * 0.035;
|
||||
smoothY += (pointerY - smoothY) * 0.035;
|
||||
scene.style.setProperty('--factory-parallax-x', `${smoothX * -18}px`);
|
||||
scene.style.setProperty('--factory-parallax-y', `${smoothY * -10}px`);
|
||||
|
||||
drawEnergyStream(time * 0.001, 0.68, 'rgba(255, 181, 73, .58)', 1.2, 4);
|
||||
drawEnergyStream(time * 0.001, 0.73, 'rgba(47, 211, 255, .62)', 1.65, 6);
|
||||
particles.forEach((particle) => drawParticle(particle, time, deltaMs));
|
||||
|
||||
if (!reducedMotion && visible) frameId = requestAnimationFrame(render);
|
||||
};
|
||||
|
||||
const onVisibilityChange = () => {
|
||||
visible = !document.hidden;
|
||||
if (visible && !reducedMotion) {
|
||||
cancelAnimationFrame(frameId);
|
||||
lastFrameTime = 0;
|
||||
frameId = requestAnimationFrame(render);
|
||||
}
|
||||
};
|
||||
|
||||
const onResize = () => {
|
||||
resize();
|
||||
if (reducedMotion) {
|
||||
lastFrameTime = 0;
|
||||
render(performance.now());
|
||||
}
|
||||
};
|
||||
|
||||
const onMotionPreferenceChange = (event) => {
|
||||
reducedMotion = event.matches;
|
||||
cancelAnimationFrame(frameId);
|
||||
lastFrameTime = 0;
|
||||
render(performance.now());
|
||||
};
|
||||
|
||||
resize();
|
||||
render();
|
||||
window.addEventListener('resize', onResize);
|
||||
window.addEventListener('pointermove', onPointerMove, { passive: true });
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
motionQuery.addEventListener('change', onMotionPreferenceChange);
|
||||
|
||||
return () => {
|
||||
cancelAnimationFrame(frameId);
|
||||
window.removeEventListener('resize', onResize);
|
||||
window.removeEventListener('pointermove', onPointerMove);
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
motionQuery.removeEventListener('change', onMotionPreferenceChange);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div ref={sceneRef} className='token-factory-scene' aria-hidden='true'>
|
||||
<div className='token-factory-scene__image' />
|
||||
<div className='token-factory-scene__grade' />
|
||||
<div className='token-factory-scene__beam token-factory-scene__beam--warm' />
|
||||
<div className='token-factory-scene__beam token-factory-scene__beam--cool' />
|
||||
<div className='token-factory-scene__haze' />
|
||||
<canvas ref={canvasRef} className='token-factory-scene__particles' />
|
||||
<div className='token-factory-scene__vignette' />
|
||||
<div className='token-factory-scene__grain' />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CinematicTokenFactory;
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user