-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (25 loc) · 945 Bytes
/
Copy pathscript.js
File metadata and controls
29 lines (25 loc) · 945 Bytes
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
// Create audio variable
var audio = new Audio("assets/audios/click.mp3");
// Function to get HSL value from sliders
function getHSL(){
var h = document.getElementById("hue").value;
var s = document.getElementById("saturation").value;
var l = document.getElementById("lightness").value;
var HSL = `hsl(${h}, ${s}%, ${l}%)`;
return HSL;
}
// Function to set HSL value to button and update color square
function setHSL(HSL = getHSL()){
button = document.getElementById("HSL").innerText = HSL;
var root = document.querySelector(":root");
root.style.setProperty("--square_color", `${HSL}`);
}
// Function to copy HSL value to clipboard
function copy(){
// Play audio when button is clicked
audio.play();
//Copy button text to clipboard
navigator.clipboard.writeText(document.getElementById("HSL").innerText);
}
// Update HSL value continuously
setInterval(setHSL, 0);