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) {
|
||||
case "rgbColor":
|
||||
colorValue = "red";
|
||||
colorValue = rgbColor();
|
||||
break;
|
||||
case "whiteColor":
|
||||
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();
|
||||
Loading…
Reference in a new issue