-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
42 lines (35 loc) · 1.24 KB
/
app.js
File metadata and controls
42 lines (35 loc) · 1.24 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
let code = document.getElementById("code");
let main = document.getElementById("main");
function hexColor() {
let value = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F"];
let hexTag = "#";
for (i = 0; i <= 5; i++) {
hexTag += value[Math.floor(Math.random() * 16)];
};
main.style.backgroundColor = hexTag;
code.innerHTML = hexTag;
console.log(hexTag);
};
function rgbColor() {
let redColor = Math.round(Math.random() * 255);
let greenColor = Math.round(Math.random() * 255);
let blueColor = Math.round(Math.random() * 255);
let rgbBg = `rgb(${redColor}, ${greenColor}, ${blueColor})`;
main.style.backgroundColor = rgbBg;
code.innerHTML = rgbBg;
console.log(rgbBg);
} ;
function rgbaColor(){
let redColor = Math.round(Math.random() * 255);
let greenColor = Math.round(Math.random() * 255);
let blueColor = Math.round(Math.random() * 255);
let alphaColor = +Math.random().toFixed(1) ;
let rgbaBg = `rgba(${redColor}, ${greenColor}, ${blueColor}, ${alphaColor})`;
main.style.backgroundColor = rgbaBg;
code.innerHTML = rgbaBg;
console.log(rgbaBg);
};
function replaceColor(){
main.style.backgroundColor = "";
code.innerHTML = "";
}