mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #332 : always use lowercase hexstring format for colors
This commit is contained in:
parent
7fea616f0f
commit
82510314a5
@ -18,6 +18,6 @@
|
|||||||
b : parseInt(matches[3], 10)
|
b : parseInt(matches[3], 10)
|
||||||
});
|
});
|
||||||
|
|
||||||
return color.toRgbString();
|
return color.toHexString();
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
ns.PalettePalReader.prototype.extractColorFromLine = function (line) {
|
ns.PalettePalReader.prototype.extractColorFromLine = function (line) {
|
||||||
var matches = line.match(RE_COLOR_LINE);
|
var matches = line.match(RE_COLOR_LINE);
|
||||||
var color = 'rgb(' + matches[1] + ',' + matches[2] + ',' + matches[3] + ')';
|
var rgbColor = 'rgb(' + matches[1] + ',' + matches[2] + ',' + matches[3] + ')';
|
||||||
return color;
|
var color = window.tinycolor(rgbColor);
|
||||||
|
|
||||||
|
return color.toHexString();
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -12,6 +12,6 @@
|
|||||||
ns.PaletteTxtReader.prototype.extractColorFromLine = function (line) {
|
ns.PaletteTxtReader.prototype.extractColorFromLine = function (line) {
|
||||||
var matches = line.match(RE_COLOR_LINE);
|
var matches = line.match(RE_COLOR_LINE);
|
||||||
var color = '#' + matches[1] + matches[2] + matches[3];
|
var color = '#' + matches[1] + matches[2] + matches[3];
|
||||||
return color;
|
return color.toLowerCase();
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -73,6 +73,6 @@
|
|||||||
usedPixels[key] = true;
|
usedPixels[key] = true;
|
||||||
|
|
||||||
// Convert tinycolor color to string format.
|
// Convert tinycolor color to string format.
|
||||||
return color.toRgbString();
|
return color.toHexString();
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -71,10 +71,10 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.ColorsList.prototype.onColorUpdated_ = function (color) {
|
ns.ColorsList.prototype.onColorUpdated_ = function (color) {
|
||||||
var rgbColor = color.toRgbString();
|
var strColor = color.toHexString();
|
||||||
this.colorPreviewEl.style.background = rgbColor;
|
this.colorPreviewEl.style.background = strColor;
|
||||||
if (this.palette) {
|
if (this.palette) {
|
||||||
this.palette.set(this.selectedIndex, rgbColor);
|
this.palette.set(this.selectedIndex, strColor);
|
||||||
this.refreshColorElement_(this.selectedIndex);
|
this.refreshColorElement_(this.selectedIndex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
var hexRe = (/^#([a-f0-9]{3}){1,2}$/i);
|
var hexRe = (/^#([a-f0-9]{3}){1,2}$/i);
|
||||||
var rgbRe = (/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/i);
|
var rgbRe = (/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/i);
|
||||||
if (hexRe.test(color)) {
|
if (hexRe.test(color)) {
|
||||||
return color.toUpperCase();
|
return color.toLowerCase();
|
||||||
} else if (rgbRe.test(color)) {
|
} else if (rgbRe.test(color)) {
|
||||||
var exec = rgbRe.exec(color);
|
var exec = rgbRe.exec(color);
|
||||||
return rgbToHex(exec[1] * 1, exec[2] * 1, exec[3] * 1);
|
return rgbToHex(exec[1] * 1, exec[2] * 1, exec[3] * 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user