mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Rename Color#getCssString() to #toCssString(), to go with #toString().
This commit is contained in:
parent
2f63a65ded
commit
cbe29fd02b
5 changed files with 11 additions and 11 deletions
|
@ -54,7 +54,7 @@ var GradientColor = Color.extend({
|
|||
}
|
||||
for (var i = 0, l = this.gradient.stops.length; i < l; i++) {
|
||||
var stop = this.gradient.stops[i];
|
||||
gradient.addColorStop(stop.rampPoint, stop.color.getCssString());
|
||||
gradient.addColorStop(stop.rampPoint, stop.color.toCssString());
|
||||
}
|
||||
return gradient;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ var GrayColor = Color.extend({
|
|||
+ ' }';
|
||||
},
|
||||
|
||||
getCssString: function() {
|
||||
toCssString: function() {
|
||||
if (!this._cssString) {
|
||||
var component = Math.round((1 - this.gray) * 255) + ',';
|
||||
this._cssString = 'rgba('
|
||||
|
|
|
@ -187,7 +187,7 @@ var RGBColor = Color.extend(new function() {
|
|||
+ ' }';
|
||||
},
|
||||
|
||||
getCssString: function() {
|
||||
toCssString: function() {
|
||||
if (!this._cssString) {
|
||||
this._cssString = 'rgba('
|
||||
+ (Math.round(this.red * 255)) + ', '
|
||||
|
|
|
@ -67,11 +67,11 @@ var CompoundPath = PathItem.extend({
|
|||
}
|
||||
firstChild.setCtxStyles(ctx);
|
||||
if (firstChild.fillColor) {
|
||||
ctx.fillStyle = firstChild.fillColor.getCssString();
|
||||
ctx.fillStyle = firstChild.fillColor.toCssString();
|
||||
ctx.fill();
|
||||
}
|
||||
if (firstChild.strokeColor) {
|
||||
ctx.strokeStyle = firstChild.strokeColor.getCssString();
|
||||
ctx.strokeStyle = firstChild.strokeColor.toCssString();
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ test('Set named color', function() {
|
|||
var path = new Path();
|
||||
path.fillColor = 'red';
|
||||
compareRGBColors(path.fillColor, new RGBColor(1, 0, 0));
|
||||
equals(path.fillColor.getCssString(), 'rgba(255, 0, 0, 1)');
|
||||
equals(path.fillColor.toCssString(), 'rgba(255, 0, 0, 1)');
|
||||
});
|
||||
|
||||
test('Set color to hex', function() {
|
||||
|
@ -13,12 +13,12 @@ test('Set color to hex', function() {
|
|||
var path = new Path();
|
||||
path.fillColor = '#ff0000';
|
||||
compareRGBColors(path.fillColor, new RGBColor(1, 0, 0));
|
||||
equals(path.fillColor.getCssString(), 'rgba(255, 0, 0, 1)');
|
||||
equals(path.fillColor.toCssString(), 'rgba(255, 0, 0, 1)');
|
||||
|
||||
var path = new Path();
|
||||
path.fillColor = '#f00';
|
||||
compareRGBColors(path.fillColor, new RGBColor(1, 0, 0));
|
||||
equals(path.fillColor.getCssString(), 'rgba(255, 0, 0, 1)');
|
||||
equals(path.fillColor.toCssString(), 'rgba(255, 0, 0, 1)');
|
||||
});
|
||||
|
||||
test('Set color to object', function() {
|
||||
|
@ -26,12 +26,12 @@ 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.getCssString(), 'rgba(255, 0, 255, 1)');
|
||||
equals(path.fillColor.toCssString(), 'rgba(255, 0, 255, 1)');
|
||||
|
||||
var path = new Path();
|
||||
path.fillColor = { gray: 0.2 };
|
||||
compareRGBColors(path.fillColor, new RGBColor(0.8, 0.8, 0.8));
|
||||
equals(path.fillColor.getCssString(), 'rgba(204, 204, 204, 1)');
|
||||
equals(path.fillColor.toCssString(), 'rgba(204, 204, 204, 1)');
|
||||
});
|
||||
|
||||
test('Set color to array', function() {
|
||||
|
@ -39,7 +39,7 @@ 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.getCssString(), 'rgba(255, 0, 0, 1)');
|
||||
equals(path.fillColor.toCssString(), 'rgba(255, 0, 0, 1)');
|
||||
});
|
||||
|
||||
test('Get gray from RGBColor', function() {
|
||||
|
|
Loading…
Reference in a new issue