Page4 HTML
Page4 HTML
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Smooth Chakra Color Motion Simulation - Grid</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.grid {
display: grid;
grid-template-columns: repeat(16, 25px);
grid-gap: 5px;
}
.square {
width: 25px;
height: 25px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<h1>Smooth Chakra Color Motion Simulation - Grid</h1>
<div class="grid" id="grid"></div>
<script>
// Define the chakra colors in Lab color space
const chakraColors = [
{ L: 53, a: 80, b: 67 }, // Red
{ L: 66, a: 49, b: 78 }, // Orange
{ L: 97, a: -11, b: 92 }, // Yellow
{ L: 87, a: -31, b: 36 }, // Green
{ L: 32, a: 79, b: -108 }, // Blue
{ L: 24, a: 52, b: -60 }, // Indigo
{ L: 29, a: 66, b: -43 } // Violet
];
function animateSquare(square) {
let startTime = null;
let currentColor = getRandomChakraColor();
let targetColor = { L: 100, a: 0, b: 0 }; // White in Lab color space
function animate(timestamp) {
if (!startTime) startTime = timestamp;
const elapsed = timestamp - startTime;
const progress = elapsed / transitionTime;
// Interpolate colors
const interpolatedColor = interpolateColors(currentColor,
targetColor, progress);
drawSquare(square, interpolatedColor);
// Continue animation
animationIntervals.push(requestAnimationFrame(animate));
}
function labToRgb(L, a, b) {
// Convert Lab to XYZ
const delta = 6 / 29;
const fy = (L + 16) / 116;
const fx = fy + (a / 500);
const fz = fy - (b / 200);
function getRandomChakraColor() {
const randomIndex = Math.floor(Math.random() * chakraColors.length);
return chakraColors[randomIndex];
}
</script>
</body>
</html>