mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-09 22:34:43 +00:00
commit
b9ca706d4a
2 changed files with 26 additions and 1 deletions
|
|
@ -3,7 +3,7 @@
|
|||
/* _FROM_SVG_START_ */
|
||||
function getColorStop(el) {
|
||||
var style = el.getAttribute('style'),
|
||||
offset = el.getAttribute('offset'),
|
||||
offset = el.getAttribute('offset') || 0,
|
||||
color, colorAlpha, opacity;
|
||||
|
||||
// convert percents to absolute values
|
||||
|
|
|
|||
|
|
@ -177,6 +177,31 @@
|
|||
equal(gradient.colorStops[0].opacity, 0);
|
||||
});
|
||||
|
||||
test('fromElement without stop', function() {
|
||||
ok(typeof fabric.Gradient.fromElement == 'function');
|
||||
|
||||
var element = fabric.document.createElement('linearGradient');
|
||||
var stop1 = fabric.document.createElement('stop');
|
||||
var stop2 = fabric.document.createElement('stop');
|
||||
|
||||
stop1.setAttribute('stop-color', 'white');
|
||||
|
||||
stop2.setAttribute('offset', '100%');
|
||||
stop2.setAttribute('stop-color', 'black');
|
||||
stop2.setAttribute('stop-opacity', '0');
|
||||
|
||||
element.appendChild(stop1);
|
||||
element.appendChild(stop2);
|
||||
|
||||
var object = new fabric.Object({ width: 100, height: 100 });
|
||||
var gradient = fabric.Gradient.fromElement(element, object);
|
||||
|
||||
ok(gradient instanceof fabric.Gradient);
|
||||
|
||||
equal(gradient.colorStops[0].offset, 1);
|
||||
equal(gradient.colorStops[1].offset, 0);
|
||||
});
|
||||
|
||||
test('fromElement radialGradient', function() {
|
||||
ok(typeof fabric.Gradient.fromElement == 'function');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue