Add colorpicker and rainbow mode toggle
This commit is contained in:
parent
885b03df6b
commit
8ebcb12843
3 changed files with 77 additions and 3 deletions
15
globals.js
15
globals.js
|
@ -127,3 +127,18 @@ function controllerChange(number, value) {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
function toggleRainbowMode(cb) {
|
||||
rainbowMode = cb.checked;
|
||||
if (rainbowMode)
|
||||
select('#colorpicker').attribute('disabled', true)
|
||||
else
|
||||
select('#colorpicker').removeAttribute('disabled')
|
||||
}
|
||||
|
||||
function changeColor() {
|
||||
keyOnColor = pedaledColor = color(select('#colorpicker').value());
|
||||
darkenedColor = keyOnColor.levels.map(x => floor(x * .7));
|
||||
pedaledColor = color(`rgb(${darkenedColor[0]}, ${darkenedColor[1]}, ${darkenedColor[2]})`)
|
||||
console.log(pedaledColor.levels);
|
||||
}
|
17
index.html
17
index.html
|
@ -17,10 +17,27 @@
|
|||
<div id="controls" class="center">
|
||||
<div>
|
||||
<h3>鋼琴鍵盤顯示器 by NiceChord</h3>
|
||||
<div style="display: flex; justify-content: space-around;">
|
||||
<div>
|
||||
<h5>選擇 MIDI 裝置</h5>
|
||||
<input id="slider" type="range" min="0" max="0" value="0">
|
||||
<div id="device">Select Input: </div>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: column; justify-content: center; align-items: start;">
|
||||
<div>
|
||||
<label for="colorpicker">選擇顏色</label>
|
||||
<input type="color" id="colorpicker" value="#ff0090" oninput="changeColor()">
|
||||
</div>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<span style="margin-right: 5px;">彩虹模式</span>
|
||||
<input type="checkbox" id="rainbow-mode-checkbox" onclick="toggleRainbowMode(this)">
|
||||
<label for="rainbow-mode-checkbox">
|
||||
<span class="switch-txt" turnOn="On" turnOff="Off"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
</div>
|
||||
|
|
42
style.css
42
style.css
|
@ -545,3 +545,45 @@ template {
|
|||
[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
input[type=checkbox] {
|
||||
height: 0;
|
||||
width: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
label[for=rainbow-mode-checkbox] {
|
||||
cursor: pointer;
|
||||
width: 50px;
|
||||
height: 25px;
|
||||
background: grey;
|
||||
display: inline-block;
|
||||
border-radius: 25px;
|
||||
position: relative;
|
||||
transition: .3s;
|
||||
}
|
||||
|
||||
label[for=rainbow-mode-checkbox]:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 1.25px;
|
||||
left: 1.25px;
|
||||
width: 22.5px;
|
||||
height: 22.5px;
|
||||
background: #fff;
|
||||
border-radius: 22.5px;
|
||||
transition: .3s;
|
||||
}
|
||||
|
||||
input:checked + label[for=rainbow-mode-checkbox] {
|
||||
background: #6f42c1;
|
||||
}
|
||||
|
||||
label[for=rainbow-mode-checkbox]:active:after {
|
||||
width: 32.5px;
|
||||
}
|
||||
|
||||
input:checked + label[for=rainbow-mode-checkbox]:after {
|
||||
left: calc(100% - 1.25px);
|
||||
transform: translateX(-100%);
|
||||
}
|
Loading…
Reference in a new issue