-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadditive.html
More file actions
169 lines (149 loc) · 5.59 KB
/
additive.html
File metadata and controls
169 lines (149 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
<title>Color Mixing Demo</title>
<style>
body {
font-family: Arial, sans-serif;
}
#colorMixing {
margin-top: 20px;
width: 100%;
}
#additiveMixHeading {
text-align: center;
}
.container {
display: flex;
justify-content: space-around;
margin-top: 20px;
}
.color-box {
width: 30%;
/* Adjusted the width to accommodate three boxes */
height: 30vh;
text-align: center;
}
.slider-container {
text-align: left;
width: 30%;
/* Ensure sliders are aligned with the color boxes */
}
label {
margin: 4px;
padding: 5px;
border-radius: 4px;
background-color: #bbb !important;
font-weight: 600;
font-size: 1.2em;
min-width: 5em;
}
input {
width: 50%;
}
.explainText {
padding: 10px;
text-align: center;
font-size: 1rem;
}
.red {
color: red;
}
.blue {
color: blue;
}
.green {
color: green;
}
.cyan {
color: cyan;
}
.magenta {
color: magenta;
}
.yellow {
color: yellow
}
.cyan,
.magenta,
.yellow {
background-color: #bbb;
font-weight: 600;
padding: 5px;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<!---<h1>Color Mixing Demo</h1> -->
</div>
<!-- Existing sections for Additive and Subtractive Colors here -->
<div class="container">
<div id="colorMixing">
<h2 id="additiveMixHeading">Color Mixing (Two Additive Colors)</h2>
<div class="explainText">
Select two different colors using RGB sliders and see how they mix.
</div>
<div style="display: flex; justify-content: space-around; width: 100%;">
<div class="color-box">
<h3>Color 1</h3>
<div id="color1" style="width:100%;height:100%;"></div>
</div>
<div class="color-box">
<h3>Mixed </h3>
<div id="mixed-color" style="width:100%;height:100%;"></div>
</div>
<div class="color-box">
<h3>Color 2</h3>
<div id="color2" style="width:100%;height:100%;"></div>
</div>
</div>
<br><br>
<div style="display: flex; justify-content: space-around; width: 100%; margin-top: 10px;">
<div class="slider-container">
<label class="red">Red 1:</label>
<input type="range" id="r1-slider" min="0" max="255" value="50" oninput="updateMixedColor()">
<label class="green">Green 1:</label>
<input type="range" id="g1-slider" min="0" max="255" value="115" oninput="updateMixedColor()">
<label class="blue">Blue 1:</label>
<input type="range" id="b1-slider" min="0" max="255" value="220" oninput="updateMixedColor()">
</div>
<div class="slider-container">
</div>
<div class="slider-container">
<label class="red">Red 2:</label>
<input type="range" id="r2-slider" min="0" max="255" value="220" oninput="updateMixedColor()">
<label class="green">Green 2:</label>
<input type="range" id="g2-slider" min="0" max="255" value="160" oninput="updateMixedColor()">
<label class="blue">Blue 2:</label>
<input type="range" id="b2-slider" min="0" max="255" value="70" oninput="updateMixedColor()">
</div>
</div>
</div>
</div>
<script>
function updateMixedColor() {
var r1 = parseInt(document.getElementById("r1-slider").value);
var g1 = parseInt(document.getElementById("g1-slider").value);
var b1 = parseInt(document.getElementById("b1-slider").value);
var r2 = parseInt(document.getElementById("r2-slider").value);
var g2 = parseInt(document.getElementById("g2-slider").value);
var b2 = parseInt(document.getElementById("b2-slider").value);
var mixedR = (r1 + r2 /2);
var mixedG = (g1 + g2 /2);
var mixedB = (b1 + b2 /2);
document.getElementById("color1").style.backgroundColor = `rgb(${r1},${g1},${b1})`;
document.getElementById("color2").style.backgroundColor = `rgb(${r2},${g2},${b2})`;
document.getElementById("mixed-color").style.backgroundColor = `rgb(${mixedR},${mixedG},${mixedB})`;
}
updateMixedColor(); // Initialize colors on page load
</script>
</body>
</html>