the
This commit is contained in:
parent
3f4b4a3868
commit
0876474457
|
|
@ -1,44 +1,47 @@
|
||||||
function pixelColorPick(pixel,customColor=null) {
|
window.addEventListener('load', function() {
|
||||||
var element = pixel.element;
|
console.log("attempted override")
|
||||||
var elementInfo = elements[element];
|
pixelColorPick = function(pixel,customColor=null) {
|
||||||
//if (elementInfo.behavior instanceof Array) {
|
var element = pixel.element;
|
||||||
|
var elementInfo = elements[element];
|
||||||
|
//if (elementInfo.behavior instanceof Array) {
|
||||||
|
|
||||||
if (pixel.charge && elementInfo.colorOn) {
|
if (pixel.charge && elementInfo.colorOn) {
|
||||||
customColor = elementInfo.colorOn;
|
customColor = elementInfo.colorOn;
|
||||||
}
|
|
||||||
if (customColor != null) {
|
|
||||||
if (Array.isArray(customColor)) {
|
|
||||||
customColor = customColor[0];
|
|
||||||
}
|
}
|
||||||
if (customColor.startsWith("#")) {
|
if (customColor != null) {
|
||||||
customColor = hexToRGB(customColor);
|
if (Array.isArray(customColor)) {
|
||||||
|
customColor = customColor[0];
|
||||||
|
}
|
||||||
|
if (customColor.startsWith("#")) {
|
||||||
|
customColor = hexToRGB(customColor);
|
||||||
|
}
|
||||||
|
var rgb = customColor;
|
||||||
}
|
}
|
||||||
var rgb = customColor;
|
else {
|
||||||
}
|
var rgb = elements[element].colorObject; // {r, g, b}
|
||||||
else {
|
// If rgb is an array, choose a random item
|
||||||
var rgb = elements[element].colorObject; // {r, g, b}
|
if (Array.isArray(rgb)) {
|
||||||
// If rgb is an array, choose a random item
|
rgb = rgb[0];
|
||||||
if (Array.isArray(rgb)) {
|
}
|
||||||
rgb = rgb[0];
|
|
||||||
}
|
}
|
||||||
}
|
// Randomly darken or lighten the RGB color
|
||||||
// Randomly darken or lighten the RGB color
|
var coloroffset = Math.floor(Math.random() * (Math.random() > 0.5 ? -1 : 1) * Math.random() * 15);
|
||||||
var coloroffset = Math.floor(Math.random() * (Math.random() > 0.5 ? -1 : 1) * Math.random() * 15);
|
var r = rgb.r + 0;
|
||||||
var r = rgb.r + coloroffset;
|
var g = rgb.g + 0;
|
||||||
var g = rgb.g + coloroffset;
|
var b = rgb.b + 0;
|
||||||
var b = rgb.b + coloroffset;
|
// Make sure the color is within the RGB range
|
||||||
// Make sure the color is within the RGB range
|
r = Math.max(0, Math.min(255, r));
|
||||||
r = Math.max(0, Math.min(255, r));
|
g = Math.max(0, Math.min(255, g));
|
||||||
g = Math.max(0, Math.min(255, g));
|
b = Math.max(0, Math.min(255, b));
|
||||||
b = Math.max(0, Math.min(255, b));
|
var color = "rgb("+r+","+g+","+b+")";
|
||||||
var color = "rgb("+r+","+g+","+b+")";
|
|
||||||
|
|
||||||
/*}
|
/*}
|
||||||
else {
|
else {
|
||||||
var color = elementInfo.color;
|
var color = elementInfo.color;
|
||||||
if (Array.isArray(color)) {
|
if (Array.isArray(color)) {
|
||||||
color = color[Math.floor(Math.random() * color.length)];
|
color = color[Math.floor(Math.random() * color.length)];
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue