Fix gradient colorStops initialization. Thanks @Kienz

This commit is contained in:
kangax 2013-03-18 13:11:31 +01:00
parent 9bb38c144c
commit e8e32e80de
5 changed files with 17 additions and 14 deletions

2
dist/all.js vendored
View file

@ -4589,7 +4589,7 @@ fabric.util.string = {
this.coords = coords;
this.gradientUnits = options.gradientUnits || 'objectBoundingBox';
this.colorStops = fabric.util.object.clone(options.colorStops);
this.colorStops = options.colorStops.slice();
},
/**

2
dist/all.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/all.min.js.gz vendored

Binary file not shown.

View file

@ -82,7 +82,7 @@
this.coords = coords;
this.gradientUnits = options.gradientUnits || 'objectBoundingBox';
this.colorStops = fabric.util.object.clone(options.colorStops);
this.colorStops = options.colorStops.slice();
},
/**

View file

@ -10,10 +10,10 @@
x2: 100,
y2: 200,
},
colorStops: {
'0': 'red',
'1': 'green'
}
colorStops: [
{ offset: 0, color: 'red' },
{ offset: 1, color: 'green' }
]
});
}
@ -32,8 +32,11 @@
equal(gradient.coords.x2, 100);
equal(gradient.coords.y2, 200);
equal(gradient.colorStops['0'], 'red');
equal(gradient.colorStops['1'], 'green');
equal(gradient.colorStops[0].offset, 0);
equal(gradient.colorStops[0].color, 'red');
equal(gradient.colorStops[1].offset, 1);
equal(gradient.colorStops[1].color, 'green');
});
test('toObject', function() {
@ -105,11 +108,11 @@
x2: 20,
y2: 20,
},
colorStops: {
'0': 'red',
'0.5': 'green',
'1': 'blue'
}
colorStops: [
{ offset: 0, color: 'red' },
{ offset: 0.5, color: 'green' },
{ offset: 1, color: 'blue' }
]
});
ok(gradient instanceof fabric.Gradient);