Improve various #toString() functions.

This commit is contained in:
Jürg Lehni 2011-05-02 08:57:55 +01:00
parent 0a4150a5c9
commit 26b70309a8
4 changed files with 17 additions and 17 deletions

View file

@ -173,15 +173,15 @@ var Color = this.Color = Base.extend(new function() {
},
toString: function() {
var string = '';
var parts = [];
for (var i = 0, l = this._components.length; i < l; i++) {
var component = this._components[i];
var value = this['_' + component];
if (component === 'alpha' && value == null)
value = 1;
string += (i > 0 ? ', ' : '') + component + ': ' + value;
parts.push(component + ': ' + value);
}
return '{ ' + string + ' }';
return '{ ' + parts.join(', ') + ' }';
},
toCssString: function() {

View file

@ -216,13 +216,13 @@ var Curve = this.Curve = Base.extend({
},
toString: function() {
return '{ point1: ' + this._segment1._point
+ (!this._segment1._handleOut.isZero()
? ', handle1: ' + this._segment1._handleOut : '')
+ (this._segment2._handleIn.isZero()
? ', handle2: ' + this._segment2._handleIn : '')
+ ', point2: ' + this._segment2._point
+ ' }';
var parts = [ 'point1: ' + this._segment1._point ];
if (!this._segment1._handleOut.isZero())
parts.push('handle1: ' + this._segment1._handleOut);
if (!this._segment2._handleIn.isZero())
parts.push('handle2: ' + this._segment2._handleIn);
parts.push('point2: ' + this._segment2._point);
return '{ ' + parts.join(', ') + ' }';
},
statics: {

View file

@ -139,6 +139,6 @@ CurveLocation = Base.extend({
var parameter = this.getParameter();
if (parameter != null)
parts.push('parameter: ' + parameter);
return '{ ' + parts.join(', ') + ' }'
return '{ ' + parts.join(', ') + ' }';
}
});

View file

@ -230,12 +230,12 @@ var Segment = this.Segment = Base.extend({
},
toString: function() {
return '{ point: ' + this._point
+ (!this._handleIn.isZero()
? ', handleIn: ' + this._handleIn : '')
+ (this._handleOut.isZero()
? ', handleOut: ' + this._handleOut : '')
+ ' }';
var parts = [ 'point: ' + this._point ];
if (!this._handleIn.isZero())
parts.push('handleIn: ' + this._handleIn);
if (!this._handleOut.isZero())
parts.push('handleOut: ' + this._handleOut);
return '{ ' + parts.join(', ') + ' }';
},
_transformCoordinates: function(matrix, coords, change) {