mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Rename #toCss() to #toCSS()
This commit is contained in:
parent
8c596927fb
commit
9977ec5c28
3 changed files with 10 additions and 10 deletions
|
@ -725,7 +725,7 @@ var Color = Base.extend(new function() {
|
||||||
/**
|
/**
|
||||||
* @return {String} A css string representation of the color.
|
* @return {String} A css string representation of the color.
|
||||||
*/
|
*/
|
||||||
toCss: function(noAlpha) {
|
toCSS: function(noAlpha) {
|
||||||
var components = this._convert('rgb'),
|
var components = this._convert('rgb'),
|
||||||
alpha = noAlpha || this._alpha == null ? 1 : this._alpha;
|
alpha = noAlpha || this._alpha == null ? 1 : this._alpha;
|
||||||
components = [
|
components = [
|
||||||
|
@ -744,7 +744,7 @@ var Color = Base.extend(new function() {
|
||||||
return this._canvasStyle;
|
return this._canvasStyle;
|
||||||
// Normal colors are simply represented by their css string.
|
// Normal colors are simply represented by their css string.
|
||||||
if (this._type !== 'gradient')
|
if (this._type !== 'gradient')
|
||||||
return this._canvasStyle = this.toCss();
|
return this._canvasStyle = this.toCSS();
|
||||||
// Gradient code form here onwards
|
// Gradient code form here onwards
|
||||||
var components = this._components,
|
var components = this._components,
|
||||||
gradient = components[0],
|
gradient = components[0],
|
||||||
|
|
|
@ -382,7 +382,7 @@ new function() {
|
||||||
alpha = stopColor.getAlpha();
|
alpha = stopColor.getAlpha();
|
||||||
attrs = {
|
attrs = {
|
||||||
offset: stop._rampPoint,
|
offset: stop._rampPoint,
|
||||||
'stop-color': stopColor.toCss(true)
|
'stop-color': stopColor.toCSS(true)
|
||||||
};
|
};
|
||||||
// See applyStyle for an explanation of why there are separated
|
// See applyStyle for an explanation of why there are separated
|
||||||
// opacity / color attributes.
|
// opacity / color attributes.
|
||||||
|
@ -432,7 +432,7 @@ new function() {
|
||||||
: entry.type === 'color'
|
: entry.type === 'color'
|
||||||
? value.gradient
|
? value.gradient
|
||||||
? exportGradient(value, item)
|
? exportGradient(value, item)
|
||||||
: value.toCss(true) // false for noAlpha, see above
|
: value.toCSS(true) // false for noAlpha, see above
|
||||||
: entry.type === 'array'
|
: entry.type === 'array'
|
||||||
? value.join(',')
|
? value.join(',')
|
||||||
: entry.type === 'number'
|
: entry.type === 'number'
|
||||||
|
|
|
@ -16,38 +16,38 @@ test('Set named color', function() {
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
path.fillColor = 'red';
|
path.fillColor = 'red';
|
||||||
compareColors(path.fillColor, new Color(1, 0, 0));
|
compareColors(path.fillColor, new Color(1, 0, 0));
|
||||||
equals(path.fillColor.toCss(), 'rgb(255, 0, 0)');
|
equals(path.fillColor.toCSS(), 'rgb(255, 0, 0)');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Set color to hex', function() {
|
test('Set color to hex', function() {
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
path.fillColor = '#ff0000';
|
path.fillColor = '#ff0000';
|
||||||
compareColors(path.fillColor, new Color(1, 0, 0));
|
compareColors(path.fillColor, new Color(1, 0, 0));
|
||||||
equals(path.fillColor.toCss(), 'rgb(255, 0, 0)');
|
equals(path.fillColor.toCSS(), 'rgb(255, 0, 0)');
|
||||||
|
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
path.fillColor = '#f00';
|
path.fillColor = '#f00';
|
||||||
compareColors(path.fillColor, new Color(1, 0, 0));
|
compareColors(path.fillColor, new Color(1, 0, 0));
|
||||||
equals(path.fillColor.toCss(), 'rgb(255, 0, 0)');
|
equals(path.fillColor.toCSS(), 'rgb(255, 0, 0)');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Set color to object', function() {
|
test('Set color to object', function() {
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
path.fillColor = { red: 1, green: 0, blue: 1};
|
path.fillColor = { red: 1, green: 0, blue: 1};
|
||||||
compareColors(path.fillColor, new Color(1, 0, 1));
|
compareColors(path.fillColor, new Color(1, 0, 1));
|
||||||
equals(path.fillColor.toCss(), 'rgb(255, 0, 255)');
|
equals(path.fillColor.toCSS(), 'rgb(255, 0, 255)');
|
||||||
|
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
path.fillColor = { gray: 0.2 };
|
path.fillColor = { gray: 0.2 };
|
||||||
compareColors(path.fillColor, new Color(0.2));
|
compareColors(path.fillColor, new Color(0.2));
|
||||||
equals(path.fillColor.toCss(), 'rgb(51, 51, 51)');
|
equals(path.fillColor.toCSS(), 'rgb(51, 51, 51)');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Set color to array', function() {
|
test('Set color to array', function() {
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
path.fillColor = [1, 0, 0];
|
path.fillColor = [1, 0, 0];
|
||||||
compareColors(path.fillColor, new Color(1, 0, 0));
|
compareColors(path.fillColor, new Color(1, 0, 0));
|
||||||
equals(path.fillColor.toCss(), 'rgb(255, 0, 0)');
|
equals(path.fillColor.toCSS(), 'rgb(255, 0, 0)');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Creating Colors', function() {
|
test('Creating Colors', function() {
|
||||||
|
|
Loading…
Reference in a new issue