Rename Color#toCssString() to #toCss(), and only include alpha if its < 1.

This commit is contained in:
Jürg Lehni 2012-12-01 12:31:22 -08:00
parent d16155f4fe
commit f268c6e152
4 changed files with 18 additions and 16 deletions

View file

@ -20,38 +20,38 @@ test('Set named color', function() {
var path = new Path();
path.fillColor = 'red';
compareRgbColors(path.fillColor, new RgbColor(1, 0, 0));
equals(path.fillColor.toCssString(), 'rgba(255, 0, 0, 1)');
equals(path.fillColor.toCss(), 'rgb(255, 0, 0)');
});
test('Set color to hex', function() {
var path = new Path();
path.fillColor = '#ff0000';
compareRgbColors(path.fillColor, new RgbColor(1, 0, 0));
equals(path.fillColor.toCssString(), 'rgba(255, 0, 0, 1)');
equals(path.fillColor.toCss(), 'rgb(255, 0, 0)');
var path = new Path();
path.fillColor = '#f00';
compareRgbColors(path.fillColor, new RgbColor(1, 0, 0));
equals(path.fillColor.toCssString(), 'rgba(255, 0, 0, 1)');
equals(path.fillColor.toCss(), 'rgb(255, 0, 0)');
});
test('Set color to object', function() {
var path = new Path();
path.fillColor = { red: 1, green: 0, blue: 1};
compareRgbColors(path.fillColor, new RgbColor(1, 0, 1));
equals(path.fillColor.toCssString(), 'rgba(255, 0, 255, 1)');
equals(path.fillColor.toCss(), 'rgb(255, 0, 255)');
var path = new Path();
path.fillColor = { gray: 0.2 };
compareRgbColors(path.fillColor, new RgbColor(0.8, 0.8, 0.8));
equals(path.fillColor.toCssString(), 'rgba(204, 204, 204, 1)');
equals(path.fillColor.toCss(), 'rgb(204, 204, 204)');
});
test('Set color to array', function() {
var path = new Path();
path.fillColor = [1, 0, 0];
compareRgbColors(path.fillColor, new RgbColor(1, 0, 0));
equals(path.fillColor.toCssString(), 'rgba(255, 0, 0, 1)');
equals(path.fillColor.toCss(), 'rgb(255, 0, 0)');
});
test('Creating colors', function() {