Allow hex strings for palette
This commit is contained in:
parent
16373919d4
commit
e42836b07f
@ -571,7 +571,7 @@
|
|||||||
const sendSpan = document.createElement("span");
|
const sendSpan = document.createElement("span");
|
||||||
sendSpan.id = `sendSpan${i}`;
|
sendSpan.id = `sendSpan${i}`;
|
||||||
sendSpan.onclick = function() {initiateUpload(i)};
|
sendSpan.onclick = function() {initiateUpload(i)};
|
||||||
sendSpan.setAttribute('title', `Send current editor to slot ${i}`);
|
sendSpan.setAttribute('title', `Send current editor to slot ${i}`); // perhaps Save instead of Send?
|
||||||
sendSpan.innerHTML = svgSave;
|
sendSpan.innerHTML = svgSave;
|
||||||
sendSpan.classList.add("sendSpan")
|
sendSpan.classList.add("sendSpan")
|
||||||
const editSpan = document.createElement("span");
|
const editSpan = document.createElement("span");
|
||||||
@ -583,12 +583,17 @@
|
|||||||
|
|
||||||
gradientDiv.classList.add("paletteGradients");
|
gradientDiv.classList.add("paletteGradients");
|
||||||
let gradientColors = "";
|
let gradientColors = "";
|
||||||
for (let j = 0; j < palette.palette.length; j += 4) {
|
for (let j = 0; j < palette.palette.length; j += 2) {
|
||||||
const position = palette.palette[j];
|
const position = palette.palette[j];
|
||||||
|
if (typeOf(palette.palette[j+1]) === "string") {
|
||||||
|
gradientColors += `#${palette.palette[j+1]} ${position/255*100}%, `;
|
||||||
|
} else {
|
||||||
const red = palette.palette[j + 1];
|
const red = palette.palette[j + 1];
|
||||||
const green = palette.palette[j + 2];
|
const green = palette.palette[j + 2];
|
||||||
const blue = palette.palette[j + 3];
|
const blue = palette.palette[j + 3];
|
||||||
gradientColors += `rgba(${red}, ${green}, ${blue}, 1) ${position/255*100}%, `;
|
gradientColors += `rgba(${red}, ${green}, ${blue}, 1) ${position/255*100}%, `;
|
||||||
|
j += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gradientColors = gradientColors.slice(0, -2); // remove the last comma and space
|
gradientColors = gradientColors.slice(0, -2); // remove the last comma and space
|
||||||
@ -616,12 +621,17 @@ function loadForEdit(i){
|
|||||||
|
|
||||||
let colArray = JSON.parse(gId(`palette${i}`).getAttribute("data-colarray"));
|
let colArray = JSON.parse(gId(`palette${i}`).getAttribute("data-colarray"));
|
||||||
|
|
||||||
for (let j = 0; j < colArray.length; j += 4) {
|
for (let j = 0; j < colArray.length; j += 2) {
|
||||||
const position = colArray[j];
|
const position = colArray[j];
|
||||||
|
if (typeof(colArray[j+1]) === "string") {
|
||||||
|
const hex = `#${colArray[j+1]}`;
|
||||||
|
} else {
|
||||||
const red = colArray[j + 1];
|
const red = colArray[j + 1];
|
||||||
const green = colArray[j + 2];
|
const green = colArray[j + 2];
|
||||||
const blue = colArray[j + 3];
|
const blue = colArray[j + 3];
|
||||||
const hex = rgbToHex(red, green, blue);
|
const hex = rgbToHex(red, green, blue);
|
||||||
|
j += 2;
|
||||||
|
}
|
||||||
console.log(position, hex)
|
console.log(position, hex)
|
||||||
addC(position, hex);
|
addC(position, hex);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user