Fix shade and tint functions
This commit is contained in:
parent
354bc7c4d0
commit
b59eff4192
1 changed files with 8 additions and 17 deletions
25
script.js
25
script.js
|
|
@ -84,13 +84,7 @@ function changeColor() {
|
||||||
|
|
||||||
switch (buttonID) {
|
switch (buttonID) {
|
||||||
case "whiteColor":
|
case "whiteColor":
|
||||||
colorValue = "white";
|
colorValue = "rgb(255, 255, 255)";
|
||||||
break;
|
|
||||||
case "shade":
|
|
||||||
colorValue = "#333";
|
|
||||||
break;
|
|
||||||
case "tint":
|
|
||||||
colorValue = "#eee";
|
|
||||||
break;
|
break;
|
||||||
case "opacity":
|
case "opacity":
|
||||||
colorValue = "blue";
|
colorValue = "blue";
|
||||||
|
|
@ -99,7 +93,7 @@ function changeColor() {
|
||||||
colorValue = "transparent";
|
colorValue = "transparent";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
colorValue = "black";
|
colorValue = "rgb(0, 0, 0)";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -114,21 +108,18 @@ function randomizeColor() {
|
||||||
|
|
||||||
function tintColor(value) {
|
function tintColor(value) {
|
||||||
let num = value.match(/\d+/g);
|
let num = value.match(/\d+/g);
|
||||||
r = num[0] + num[0] * 1/10;
|
r = +num[0] + (0.25 * +num[0]);
|
||||||
g = num[1] + num[1] * 1/10;
|
g = +num[1] + (0.25 * +num[0]);
|
||||||
b = num[2] + num[2] * 1/10;
|
b = +num[2] + (0.25 * +num[0]);
|
||||||
console.log(r, g, b);
|
|
||||||
|
|
||||||
return`rgb(${r},${g},${b})`;
|
return`rgb(${r},${g},${b})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function shadeColor(value) {
|
function shadeColor(value) {
|
||||||
let num = value.match(/\d+/g);
|
let num = value.match(/\d+/g);
|
||||||
r = num[0] - num[0] * 1/10;
|
r = +num[0] * .75;
|
||||||
g = num[1] - num[1] * 1/10;
|
g = +num[1] * .75;
|
||||||
b = num[2] - num[2] * 1/10;
|
b = +num[2] * .75;
|
||||||
console.log(r, g, b);
|
|
||||||
|
|
||||||
return`rgb(${r},${g},${b})`;
|
return`rgb(${r},${g},${b})`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue