|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>Color Mixing Fun!</title> |
|
<script src="https://cdn.tailwindcss.com"></script> |
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> |
|
<style> |
|
.color-droplet { |
|
width: 80px; |
|
height: 80px; |
|
border-radius: 50% 50% 60% 40% / 70% 70% 30% 30%; |
|
cursor: pointer; |
|
transition: transform 0.3s, box-shadow 0.3s; |
|
box-shadow: 0 4px 8px rgba(0,0,0,0.2); |
|
} |
|
.color-droplet:hover { |
|
transform: scale(1.1); |
|
box-shadow: 0 6px 12px rgba(0,0,0,0.3); |
|
} |
|
.mixing-bowl { |
|
width: 200px; |
|
height: 200px; |
|
border-radius: 50% 50% 60% 40% / 70% 70% 30% 30%; |
|
background-color: #f0f0f0; |
|
display: flex; |
|
justify-content: center; |
|
align-items: center; |
|
box-shadow: inset 0 0 20px rgba(0,0,0,0.1); |
|
position: relative; |
|
overflow: hidden; |
|
} |
|
.mixing-bowl::after { |
|
content: ''; |
|
position: absolute; |
|
top: 10px; |
|
left: 10px; |
|
right: 10px; |
|
bottom: 10px; |
|
border-radius: 50% 50% 60% 40% / 70% 70% 30% 30%; |
|
border: 2px dashed rgba(255,255,255,0.5); |
|
pointer-events: none; |
|
} |
|
.result-color { |
|
width: 150px; |
|
height: 150px; |
|
border-radius: 50%; |
|
transition: background-color 0.5s; |
|
display: flex; |
|
justify-content: center; |
|
align-items: center; |
|
color: white; |
|
font-weight: bold; |
|
text-shadow: 1px 1px 2px rgba(0,0,0,0.5); |
|
} |
|
.color-splash { |
|
position: absolute; |
|
width: 100%; |
|
height: 100%; |
|
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20,20 Q30,10 40,20 T60,20 T80,20" stroke="white" fill="none" stroke-width="2"/><path d="M30,30 Q40,20 50,30 T70,30 T90,30" stroke="white" fill="none" stroke-width="2"/></svg>'); |
|
background-size: 200px 200px; |
|
opacity: 0.3; |
|
animation: splash 2s infinite linear; |
|
} |
|
@keyframes splash { |
|
0% { background-position: 0 0; } |
|
100% { background-position: 200px 200px; } |
|
} |
|
.color-palette { |
|
display: grid; |
|
grid-template-columns: repeat(3, 1fr); |
|
gap: 20px; |
|
margin-top: 20px; |
|
} |
|
.color-card { |
|
border-radius: 10px; |
|
padding: 15px; |
|
text-align: center; |
|
box-shadow: 0 4px 6px rgba(0,0,0,0.1); |
|
transition: transform 0.3s; |
|
} |
|
.color-card:hover { |
|
transform: translateY(-5px); |
|
} |
|
.shake { |
|
animation: shake 0.5s; |
|
} |
|
@keyframes shake { |
|
0%, 100% { transform: translateX(0); } |
|
20%, 60% { transform: translateX(-5px); } |
|
40%, 80% { transform: translateX(5px); } |
|
} |
|
.bounce { |
|
animation: bounce 0.5s; |
|
} |
|
@keyframes bounce { |
|
0%, 100% { transform: translateY(0); } |
|
50% { transform: translateY(-10px); } |
|
} |
|
.tab-button { |
|
transition: all 0.3s; |
|
} |
|
.tab-button.active { |
|
background-color: #6b46c1; |
|
color: white; |
|
} |
|
</style> |
|
</head> |
|
<body class="bg-gradient-to-b from-blue-50 to-purple-50 min-h-screen"> |
|
<div class="container mx-auto px-4 py-8"> |
|
<header class="text-center mb-8"> |
|
<h1 class="text-4xl font-bold text-purple-800 mb-2">Color Mixing Magic!</h1> |
|
<p class="text-lg text-gray-600">Discover how primary and secondary colors mix together!</p> |
|
</header> |
|
|
|
<div class="flex justify-center mb-8"> |
|
<div class="inline-flex rounded-full bg-white shadow-md overflow-hidden"> |
|
<button id="primaryTab" class="tab-button px-6 py-2 font-medium active" onclick="showTab('primary')"> |
|
Primary Colors |
|
</button> |
|
<button id="secondaryTab" class="tab-button px-6 py-2 font-medium" onclick="showTab('secondary')"> |
|
Secondary Colors |
|
</button> |
|
</div> |
|
</div> |
|
|
|
<div id="primaryContent" class="tab-content"> |
|
<div class="flex flex-col lg:flex-row items-center justify-center gap-8 mb-12"> |
|
<div class="text-center"> |
|
<h2 class="text-2xl font-semibold text-blue-700 mb-4">Primary Colors</h2> |
|
<div class="flex gap-6 justify-center"> |
|
<div class="color-droplet bg-red-500" data-color="red" onclick="selectColor('red')"></div> |
|
<div class="color-droplet bg-blue-500" data-color="blue" onclick="selectColor('blue')"></div> |
|
<div class="color-droplet bg-yellow-500" data-color="yellow" onclick="selectColor('yellow')"></div> |
|
</div> |
|
<p class="mt-4 text-gray-600">Click on two primary colors to mix them!</p> |
|
</div> |
|
|
|
<div class="text-center"> |
|
<h2 class="text-2xl font-semibold text-purple-700 mb-4">Mixing Bowl</h2> |
|
<div class="mixing-bowl mx-auto"> |
|
<div id="resultColor" class="result-color bg-gray-200 flex flex-col items-center justify-center"> |
|
<i class="fas fa-question text-gray-500 text-4xl mb-2"></i> |
|
<span class="text-sm">Mix colors here!</span> |
|
</div> |
|
<div class="color-splash"></div> |
|
</div> |
|
<button id="resetBtn" class="mt-4 px-4 py-2 bg-gray-200 text-gray-700 rounded-full hover:bg-gray-300 transition" onclick="resetColors()"> |
|
<i class="fas fa-undo mr-2"></i>Start Over |
|
</button> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div id="secondaryContent" class="tab-content hidden"> |
|
<div class="flex flex-col lg:flex-row items-center justify-center gap-8 mb-12"> |
|
<div class="text-center"> |
|
<h2 class="text-2xl font-semibold text-green-700 mb-4">Secondary Colors</h2> |
|
<div class="flex gap-6 justify-center"> |
|
<div class="color-droplet bg-green-500" data-color="green" onclick="selectSecondaryColor('green')"></div> |
|
<div class="color-droplet bg-orange-500" data-color="orange" onclick="selectSecondaryColor('orange')"></div> |
|
<div class="color-droplet bg-purple-500" data-color="purple" onclick="selectSecondaryColor('purple')"></div> |
|
</div> |
|
<p class="mt-4 text-gray-600">Click on a secondary color to see how it's made!</p> |
|
</div> |
|
|
|
<div class="text-center"> |
|
<h2 class="text-2xl font-semibold text-purple-700 mb-4">Color Recipe</h2> |
|
<div class="mixing-bowl mx-auto"> |
|
<div id="secondaryResult" class="result-color bg-gray-200 flex flex-col items-center justify-center"> |
|
<i class="fas fa-question text-gray-500 text-4xl mb-2"></i> |
|
<span class="text-sm">Select a color to see its recipe</span> |
|
</div> |
|
<div class="color-splash"></div> |
|
</div> |
|
<div id="recipeDisplay" class="mt-4 hidden"> |
|
<div class="flex justify-center gap-4 mb-2"> |
|
<div id="ingredient1" class="color-droplet w-12 h-12"></div> |
|
<div class="flex items-center"> |
|
<i class="fas fa-plus text-gray-600"></i> |
|
</div> |
|
<div id="ingredient2" class="color-droplet w-12 h-12"></div> |
|
<div class="flex items-center"> |
|
<i class="fas fa-equals text-gray-600 ml-2"></i> |
|
</div> |
|
<div id="resultPreview" class="color-droplet w-12 h-12"></div> |
|
</div> |
|
<p id="recipeText" class="text-gray-700"></p> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div class="max-w-3xl mx-auto bg-white rounded-xl shadow-lg p-6"> |
|
<h2 class="text-2xl font-bold text-purple-800 mb-4">Color Theory</h2> |
|
<div class="color-palette"> |
|
<div class="color-card bg-red-500 text-white"> |
|
<h3 class="font-bold">Red</h3> |
|
<p>Primary Color</p> |
|
</div> |
|
<div class="color-card bg-blue-500 text-white"> |
|
<h3 class="font-bold">Blue</h3> |
|
<p>Primary Color</p> |
|
</div> |
|
<div class="color-card bg-yellow-500 text-black"> |
|
<h3 class="font-bold">Yellow</h3> |
|
<p>Primary Color</p> |
|
</div> |
|
<div class="color-card bg-green-500 text-white"> |
|
<h3 class="font-bold">Green</h3> |
|
<p>Blue + Yellow</p> |
|
</div> |
|
<div class="color-card bg-orange-500 text-white"> |
|
<h3 class="font-bold">Orange</h3> |
|
<p>Red + Yellow</p> |
|
</div> |
|
<div class="color-card bg-purple-500 text-white"> |
|
<h3 class="font-bold">Purple</h3> |
|
<p>Red + Blue</p> |
|
</div> |
|
</div> |
|
|
|
<div class="mt-8"> |
|
<h3 class="text-xl font-semibold text-gray-800 mb-3">Understanding Colors</h3> |
|
<div class="grid md:grid-cols-2 gap-6"> |
|
<div class="bg-blue-50 p-4 rounded-lg"> |
|
<h4 class="font-bold text-blue-700 mb-2"><i class="fas fa-paint-brush mr-2"></i>Primary Colors</h4> |
|
<p class="text-gray-700">These are the foundation colors that can't be created by mixing other colors. All other colors are derived from these three: red, blue, and yellow.</p> |
|
</div> |
|
<div class="bg-purple-50 p-4 rounded-lg"> |
|
<h4 class="font-bold text-purple-700 mb-2"><i class="fas fa-blender mr-2"></i>Secondary Colors</h4> |
|
<p class="text-gray-700">These are created by mixing equal parts of two primary colors. The three secondary colors are green, orange, and purple.</p> |
|
</div> |
|
</div> |
|
<div class="mt-6 bg-green-50 p-4 rounded-lg"> |
|
<h4 class="font-bold text-green-700 mb-2"><i class="fas fa-palette mr-2"></i>Color Wheel</h4> |
|
<p class="text-gray-700">When arranged in a circle, primary and secondary colors create a color wheel that shows how colors relate to each other. Colors opposite each other on the wheel are called complementary colors.</p> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div class="mt-8 text-center"> |
|
<button id="hintBtn" class="px-6 py-3 bg-yellow-400 text-yellow-900 rounded-full font-bold hover:bg-yellow-500 transition" onclick="showHint()"> |
|
<i class="fas fa-lightbulb mr-2"></i>Need a Hint? |
|
</button> |
|
<div id="hintBox" class="hidden mt-4 bg-yellow-100 border-l-4 border-yellow-500 p-4 text-yellow-800 rounded"> |
|
<p>In the Primary Colors tab, try mixing red and blue to make purple. In the Secondary Colors tab, click on green to see it's made from blue and yellow!</p> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<script> |
|
let selectedColors = []; |
|
const colorMixes = { |
|
'red+blue': 'purple', |
|
'blue+red': 'purple', |
|
'red+yellow': 'orange', |
|
'yellow+red': 'orange', |
|
'blue+yellow': 'green', |
|
'yellow+blue': 'green' |
|
}; |
|
const colorRecipes = { |
|
'green': { ingredients: ['blue', 'yellow'], text: "Green is made by mixing blue and yellow!" }, |
|
'orange': { ingredients: ['red', 'yellow'], text: "Orange is made by mixing red and yellow!" }, |
|
'purple': { ingredients: ['red', 'blue'], text: "Purple is made by mixing red and blue!" } |
|
}; |
|
const colorNames = { |
|
'red': 'Red', |
|
'blue': 'Blue', |
|
'yellow': 'Yellow', |
|
'purple': 'Purple', |
|
'orange': 'Orange', |
|
'green': 'Green' |
|
}; |
|
const colorCodes = { |
|
'red': 'bg-red-500', |
|
'blue': 'bg-blue-500', |
|
'yellow': 'bg-yellow-500', |
|
'purple': 'bg-purple-500', |
|
'orange': 'bg-orange-500', |
|
'green': 'bg-green-500' |
|
}; |
|
|
|
function showTab(tabName) { |
|
|
|
document.getElementById('primaryTab').classList.toggle('active', tabName === 'primary'); |
|
document.getElementById('secondaryTab').classList.toggle('active', tabName === 'secondary'); |
|
|
|
|
|
document.getElementById('primaryContent').classList.toggle('hidden', tabName !== 'primary'); |
|
document.getElementById('secondaryContent').classList.toggle('hidden', tabName !== 'secondary'); |
|
|
|
|
|
if (tabName === 'primary') { |
|
resetColors(); |
|
} else { |
|
document.getElementById('recipeDisplay').classList.add('hidden'); |
|
} |
|
} |
|
|
|
function selectColor(color) { |
|
if (selectedColors.length >= 2) return; |
|
|
|
const droplet = document.querySelector(`.color-droplet[data-color="${color}"]`); |
|
droplet.classList.add('bounce'); |
|
|
|
setTimeout(() => { |
|
droplet.classList.remove('bounce'); |
|
}, 500); |
|
|
|
selectedColors.push(color); |
|
|
|
if (selectedColors.length === 2) { |
|
mixColors(); |
|
} else { |
|
updateMixingBowl(); |
|
} |
|
} |
|
|
|
function selectSecondaryColor(color) { |
|
const recipe = colorRecipes[color]; |
|
const resultDiv = document.getElementById('secondaryResult'); |
|
const recipeDisplay = document.getElementById('recipeDisplay'); |
|
|
|
|
|
resultDiv.className = `result-color ${colorCodes[color]} flex items-center justify-center`; |
|
resultDiv.innerHTML = `<span class="text-xl font-bold">${colorNames[color]}</span>`; |
|
|
|
|
|
document.getElementById('ingredient1').className = `color-droplet w-12 h-12 ${colorCodes[recipe.ingredients[0]]}`; |
|
document.getElementById('ingredient2').className = `color-droplet w-12 h-12 ${colorCodes[recipe.ingredients[1]]}`; |
|
document.getElementById('resultPreview').className = `color-droplet w-12 h-12 ${colorCodes[color]}`; |
|
document.getElementById('recipeText').textContent = recipe.text; |
|
|
|
recipeDisplay.classList.remove('hidden'); |
|
|
|
|
|
resultDiv.classList.add('bounce'); |
|
setTimeout(() => { |
|
resultDiv.classList.remove('bounce'); |
|
}, 1000); |
|
|
|
|
|
showConfetti(); |
|
} |
|
|
|
function updateMixingBowl() { |
|
const resultDiv = document.getElementById('resultColor'); |
|
|
|
if (selectedColors.length === 0) { |
|
resultDiv.className = 'result-color bg-gray-200 flex flex-col items-center justify-center'; |
|
resultDiv.innerHTML = '<i class="fas fa-question text-gray-500 text-4xl mb-2"></i><span class="text-sm">Mix colors here!</span>'; |
|
} else if (selectedColors.length === 1) { |
|
const color = selectedColors[0]; |
|
resultDiv.className = `result-color ${colorCodes[color]} flex items-center justify-center`; |
|
resultDiv.innerHTML = `<i class="fas fa-plus text-white text-4xl"></i>`; |
|
} |
|
} |
|
|
|
function mixColors() { |
|
const color1 = selectedColors[0]; |
|
const color2 = selectedColors[1]; |
|
const mixKey = `${color1}+${color2}`; |
|
|
|
const resultDiv = document.getElementById('resultColor'); |
|
|
|
if (colorMixes[mixKey]) { |
|
const resultColor = colorMixes[mixKey]; |
|
resultDiv.className = `result-color ${colorCodes[resultColor]} flex items-center justify-center`; |
|
resultDiv.innerHTML = ` |
|
<span class="text-xl font-bold">${colorNames[resultColor]}</span> |
|
<span class="text-sm">${colorNames[color1]} + ${colorNames[color2]}</span> |
|
`; |
|
|
|
|
|
resultDiv.classList.add('bounce'); |
|
setTimeout(() => { |
|
resultDiv.classList.remove('bounce'); |
|
}, 1000); |
|
|
|
|
|
showConfetti(); |
|
} else { |
|
|
|
resultDiv.className = `result-color ${colorCodes[color1]} flex items-center justify-center`; |
|
resultDiv.innerHTML = ` |
|
<span class="text-xl font-bold">More ${colorNames[color1]}</span> |
|
<span class="text-sm">Try mixing different colors!</span> |
|
`; |
|
resultDiv.classList.add('shake'); |
|
setTimeout(() => { |
|
resultDiv.classList.remove('shake'); |
|
}, 500); |
|
} |
|
} |
|
|
|
function resetColors() { |
|
selectedColors = []; |
|
updateMixingBowl(); |
|
|
|
const btn = document.getElementById('resetBtn'); |
|
btn.classList.add('bg-gray-300'); |
|
setTimeout(() => { |
|
btn.classList.remove('bg-gray-300'); |
|
}, 300); |
|
} |
|
|
|
function showHint() { |
|
const hintBox = document.getElementById('hintBox'); |
|
hintBox.classList.toggle('hidden'); |
|
|
|
const btn = document.getElementById('hintBtn'); |
|
btn.classList.add('bg-yellow-500'); |
|
setTimeout(() => { |
|
btn.classList.remove('bg-yellow-500'); |
|
}, 300); |
|
} |
|
|
|
function showConfetti() { |
|
|
|
const colors = ['red', 'blue', 'yellow', 'green', 'orange', 'purple']; |
|
const container = document.querySelector('.mixing-bowl'); |
|
|
|
for (let i = 0; i < 20; i++) { |
|
const confetti = document.createElement('div'); |
|
confetti.className = 'absolute w-2 h-2 rounded-full'; |
|
confetti.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)]; |
|
confetti.style.left = Math.random() * 180 + 'px'; |
|
confetti.style.top = Math.random() * 180 + 'px'; |
|
confetti.style.transform = `rotate(${Math.random() * 360}deg)`; |
|
confetti.style.opacity = '0.8'; |
|
|
|
container.appendChild(confetti); |
|
|
|
|
|
const animation = confetti.animate([ |
|
{ transform: `translate(0, 0) rotate(0deg)`, opacity: 0.8 }, |
|
{ transform: `translate(${Math.random() * 100 - 50}px, ${Math.random() * 100 - 50}px) rotate(${Math.random() * 360}deg)`, opacity: 0 } |
|
], { |
|
duration: 1000, |
|
easing: 'cubic-bezier(0.1, 0.8, 0.9, 1)' |
|
}); |
|
|
|
animation.onfinish = () => confetti.remove(); |
|
} |
|
} |
|
</script> |
|
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=pp/primary-and-secondary-colors-k5" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body> |
|
</html> |