Randomize rgb color
This commit is contained in:
parent
07e267b3ab
commit
34aa91359b
1 changed files with 11 additions and 1 deletions
12
script.js
12
script.js
|
|
@ -54,7 +54,7 @@ function changeColor() {
|
||||||
|
|
||||||
switch (buttonID) {
|
switch (buttonID) {
|
||||||
case "rgbColor":
|
case "rgbColor":
|
||||||
colorValue = "red";
|
colorValue = rgbColor();
|
||||||
break;
|
break;
|
||||||
case "whiteColor":
|
case "whiteColor":
|
||||||
colorValue = "white";
|
colorValue = "white";
|
||||||
|
|
@ -77,4 +77,14 @@ function changeColor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rgbColor() {
|
||||||
|
let r = Math.floor(Math.random() * 255);
|
||||||
|
let g = Math.floor(Math.random() * 255);
|
||||||
|
let b = Math.floor(Math.random() * 255);
|
||||||
|
|
||||||
|
let rgbCol = "rgb(" + r + "," + g+ "," + b +")";
|
||||||
|
|
||||||
|
return rgbCol;
|
||||||
|
}
|
||||||
|
|
||||||
createGrid();
|
createGrid();
|
||||||
Loading…
Reference in a new issue