Merge pull request #343 from juliandescottes/fix-color-format

Issue #332 : always use lowercase hexstring format for colors
This commit is contained in:
Julian Descottes 2015-11-27 23:05:09 +01:00
commit 26f4448175
6 changed files with 11 additions and 9 deletions

View File

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

View File

@ -11,7 +11,9 @@
ns.PalettePalReader.prototype.extractColorFromLine = function (line) {
var matches = line.match(RE_COLOR_LINE);
var color = 'rgb(' + matches[1] + ',' + matches[2] + ',' + matches[3] + ')';
return color;
var rgbColor = 'rgb(' + matches[1] + ',' + matches[2] + ',' + matches[3] + ')';
var color = window.tinycolor(rgbColor);
return color.toHexString();
};
})();

View File

@ -12,6 +12,6 @@
ns.PaletteTxtReader.prototype.extractColorFromLine = function (line) {
var matches = line.match(RE_COLOR_LINE);
var color = '#' + matches[1] + matches[2] + matches[3];
return color;
return color.toLowerCase();
};
})();

View File

@ -73,6 +73,6 @@
usedPixels[key] = true;
// Convert tinycolor color to string format.
return color.toRgbString();
return color.toHexString();
};
})();

View File

@ -71,10 +71,10 @@
};
ns.ColorsList.prototype.onColorUpdated_ = function (color) {
var rgbColor = color.toRgbString();
this.colorPreviewEl.style.background = rgbColor;
var strColor = color.toHexString();
this.colorPreviewEl.style.background = strColor;
if (this.palette) {
this.palette.set(this.selectedIndex, rgbColor);
this.palette.set(this.selectedIndex, strColor);
this.refreshColorElement_(this.selectedIndex);
}
};

View File

@ -17,7 +17,7 @@
var hexRe = (/^#([a-f0-9]{3}){1,2}$/i);
var rgbRe = (/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/i);
if (hexRe.test(color)) {
return color.toUpperCase();
return color.toLowerCase();
} else if (rgbRe.test(color)) {
var exec = rgbRe.exec(color);
return rgbToHex(exec[1] * 1, exec[2] * 1, exec[3] * 1);