Issue #332 : always use lowercase hexstring format for colors

This commit is contained in:
jdescottes 2015-11-27 22:58:11 +01:00
parent 7fea616f0f
commit 82510314a5
6 changed files with 11 additions and 9 deletions

View File

@ -18,6 +18,6 @@
b : parseInt(matches[3], 10) b : parseInt(matches[3], 10)
}); });
return color.toRgbString(); return color.toHexString();
}; };
})(); })();

View File

@ -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();
}; };
})(); })();

View File

@ -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();
}; };
})(); })();

View File

@ -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();
}; };
})(); })();

View File

@ -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);
} }
}; };

View File

@ -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);