Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
289 changes: 0 additions & 289 deletions color.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ <h1>Vedal forever enslaved by Neuro-sama</h1>
<script src="color.js"></script>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed

<script src="main.js"></script>
</body>
</html>
</html>
73 changes: 19 additions & 54 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lamp.addEventListener("click", function() {
const explosion = document.createElement("div");
explosion.style.position = "fixed";
explosion.style.top = "0";
explosion.style.left = "0";
explosion.style.left = "0";
explosion.style.width = "100vw";
explosion.style.height = "100vh";
explosion.style.background = "radial-gradient(circle at center, #ff4500, #ff8c00, #ff0000)";
Expand All @@ -23,7 +23,7 @@ lamp.addEventListener("click", function() {
lampContainer.style.transition = "all 0.2s";
lampContainer.style.transform = "scale(1.5)";
lampContainer.style.opacity = "0";

// Fade in explosion
requestAnimationFrame(() => {
explosion.style.opacity = "1";
Expand All @@ -43,63 +43,28 @@ lamp.addEventListener("click", function() {
}, 300); // Show explosion for 1 second
});

// Track current and target colors for smooth transitions
let currentValues = [0, 0, 0, 0, 0, 0];
let targetValues = [0, 0, 0, 0, 0, 0];

let solver = null;

// Linear interpolation between two values
function lerp(start, end, t) {
return start + (end - start) * t;
}

// Smoothly interpolate between colors
function updateLampColor() {

// Lerp current color towards target
const t = 0.01; // Adjust this value to control transition speed
currentValues[0] = lerp(currentValues[0], targetValues[0], t);
currentValues[1] = lerp(currentValues[1], targetValues[1], t);
currentValues[2] = lerp(currentValues[2], targetValues[2], t);
currentValues[3] = lerp(currentValues[3], targetValues[3], t);
currentValues[4] = lerp(currentValues[4], targetValues[4], t);
currentValues[5] = lerp(currentValues[5], targetValues[5], t);

if (solver) {
const css = solver.css(currentValues);
lamp.style = css;
}
}

let isRunningOnVedalsPC = true;
// Fetch new target color
function fetchTargetColor() {
fetch("http://localhost:8000/lamp")
.then(response => response.text())
.then(hexColor => {
hexColor = hexColor.toLowerCase().trim();
const rgb = hexToRgb(hexColor);

const color = new Color(
Math.round(rgb[0]),
Math.round(rgb[1]),
Math.round(rgb[2])
);
solver = new Solver(color);
const result = solver.solve();
targetValues = result.values;
})
.catch(error => {
console.error("Failed to fetch lamp color:", error);
});
if (isRunningOnVedalsPC) {
fetch("http://localhost:8000/lamp")
.then(response => response.text())
.then(response => {
lampContainer.style.backgroundColor = response.trim();
})
.catch(error => {
isRunningOnVedalsPC = false;
console.error("Failed to fetch lamp color:", error);
});
}
else {
lampContainer.style.backgroundColor = `hsl(${Math.random()*360}deg 60% 50%)`;
}
}

// Update interpolation frequently for smooth animation
//setInterval(updateLampColor, 16); // ~60fps

// Fetch new target color less frequently
//fetchTargetColor(); // Initial fetch
//setInterval(fetchTargetColor, 500);
fetchTargetColor(); // Initial fetch
setInterval(fetchTargetColor, 3000);

// Create raining cats
function createCat() {
Expand Down
Loading