pixelplanet/src/core/exportGPL.js
HF 53b9aeeec7 send actions to popUps
log proxycheck returns again
2022-08-19 04:49:14 +02:00

37 lines
774 B
JavaScript

/*
* export palette in gimp format
*/
function appendNumberText(number) {
let appendStr = `${number} `;
if (number < 10) appendStr += ' ';
else if (number < 100) appendStr += ' ';
return appendStr;
}
function appendHexColorText(clr) {
let appendStr = ' #';
clr.forEach((z) => {
if (z < 16) appendStr += '0';
appendStr += z.toString(16);
});
return appendStr;
}
function printGIMPPalette(title, description, colors) {
let text = `GIMP Palette
#Palette Name: Pixelplanet${title}
#Description: ${description}
#Colors: ${colors.length}`;
colors.forEach((clr) => {
text += '\n';
clr.forEach((z) => {
text += appendNumberText(z);
});
text += appendHexColorText(clr);
});
return text;
}
export default printGIMPPalette;