I want a website that shows the current time in different color valves he’d hex RgB and…
- User
I want a website that shows the current time in different color valves he’d hex RgB and CMYK
- Assistant
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Time Colors</title> <style> body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; transition: background-color 1s; } .container { background-color: rgba(255, 255, 255, 0.8); padding: 30px; border-radius: 10px; box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); text-align: center; } .time { font-size: 4rem; margin-bottom: 20px; } .colors { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; text-align: left; } .color-box { height: 40px; width: 100%; margin-bottom: 5px; border-radius: 5px; } </style> </head> <body> <div class="container"> <div class="time" id="current-time">00:00:00</div> <div class="color-box" id="color-display"></div> <div class="colors"> <div> <p><strong>HSV:</strong> <span id="hsv-value"></span></p> <p><strong>HEX:</strong> <span id="hex-value"></span></p> </div> <div> <p><strong>RGB:</strong> <span id="rgb-value"></span></p> <p><strong>CMYK:</strong> <span id="cmyk-value"></span></p> </div> </div> </div> <script> function updateTime() { const now = new Date(); const hours = now.getHours(); const minutes = now.getMinutes(); const seconds = now.getSeconds(); // Format time display const timeDisplay = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`; document.getElementById('current-time').textContent = timeDisplay; // Convert time to HSV const h = Math.round((hours / 24) * 360); const s = Math.round((minutes / 60) * 100); const v = Math.round((seconds / 60) * 100); // Display HSV document.getElementById('hsv-value').textContent = `${h}°, ${s}%, ${v}%`; // Convert HSV to RGB const rgb = hsvToRgb(h, s/100, v/100); const r = Math.round(rgb[0]); const g = Math.round(rgb[1]); const b = Math.round(rgb[2]); // Display RGB document.getElementById('rgb-value').textContent = `${r}, ${g}, ${b}`; // Convert RGB to HEX const hex = rgbToHex(r, g, b); document.getElementById('hex-value').textContent = hex; // Convert RGB to CMYK const cmyk = rgbToCmyk(r, g, b); document.getElementById('cmyk-value').textContent = `${cmyk.c}%, ${cmyk.m}%, ${cmyk.y}%, ${cmyk.k}%`; // Apply color to background and color box document.body.style.backgroundColor = `rgb(${r}, ${g}, ${b})`; document.getElementById('color-display').style.backgroundColor = `rgb(${r}, ${g}, ${b})`; } // HSV to RGB conversion function hsvToRgb(h, s, v) { let r, g, b; const i = Math.floor(h / 60) % 6; const f = h / 60 - Math.floor(h / 60); const p = v * (1 - s); const q = v * (1 - f * s); const t = v * (1 - (1 - f) * s); switch (i) { case 0: r = v; g = t; b = p; break; case 1: r = q; g = v; b = p; break; case 2: r = p; g = v; b = t; break; case 3: r = p; g = q; b = v; break; case 4: r = t; g = p; b = v; break; case 5: r = v; g = p; b = q; break; } return [r * 255, g * 255, b * 255]; } // RGB to HEX conversion function rgbToHex(r, g, b) { return '#' + [r, g, b].map(x => { const hex = x.toString(16); return hex.length === 1 ? '0' + hex : hex; }).join(''); } // RGB to CMYK conversion function rgbToCmyk(r, g, b) { r = r / 255; g = g / 255; b = b / 255; const k = 1 - Math.max(r, g, b); const c = k === 1 ? 0 : Math.round(((1 - r - k) / (1 - k)) * 100); const m = k === 1 ? 0 : Math.round(((1 - g - k) / (1 - k)) * 100); const y = k === 1 ? 0 : Math.round(((1 - b - k) / (1 - k)) * 100); return { c: c, m: m, y: y, k: Math.round(k * 100) }; } // Update every second updateTime(); setInterval(updateTime, 1000); </script> </body> </html>Would you like me to explain how this code works?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.