mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-18 10:31:08 +00:00
Update gradient.class.js
Fixed some errore introduced with commit.
This commit is contained in:
parent
905097149a
commit
92604f1ee4
1 changed files with 11 additions and 8 deletions
|
|
@ -4,7 +4,7 @@
|
|||
function getColorStop(el) {
|
||||
var style = el.getAttribute('style'),
|
||||
offset = el.getAttribute('offset'),
|
||||
color, opacity;
|
||||
color, colorAlpha, opacity;
|
||||
|
||||
// convert percents to absolute values
|
||||
offset = parseFloat(offset) / (/%$/.test(offset) ? 100 : 1);
|
||||
|
|
@ -38,13 +38,16 @@
|
|||
opacity = el.getAttribute('stop-opacity');
|
||||
}
|
||||
|
||||
// convert rgba color to rgb color - alpha value has no affect in svg
|
||||
color = new fabric.Color(color).toRgb();
|
||||
color = new fabric.Color(color);
|
||||
colorAlpha = color.getAlpha();
|
||||
color = color.toRgb();
|
||||
opacity = isNaN(parseFloat(opacity)) ? 1 : parseFloat(opacity);
|
||||
opacity *= colorAlpha;
|
||||
|
||||
return {
|
||||
offset: offset,
|
||||
color: color,
|
||||
opacity: isNaN(parseFloat(opacity)) ? 1 : parseFloat(opacity)
|
||||
opacity: opacity
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -121,8 +124,8 @@
|
|||
if (options.gradientTransform) {
|
||||
this.gradientTransform = options.gradientTransform;
|
||||
}
|
||||
this.origX = options.left;
|
||||
this.orgiY = options.top;
|
||||
this.origX = options.left || this.origX;
|
||||
this.origY = options.top || this.origY;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -389,10 +392,10 @@
|
|||
for (var prop in options) {
|
||||
//convert to percent units
|
||||
if (prop === 'x1' || prop === 'x2' || prop === 'r2') {
|
||||
options[prop] = fabric.util.toFixed((options[prop] - object.origX) / object.width * 100, 2) + '%';
|
||||
options[prop] = fabric.util.toFixed((options[prop] - object.fill.origX) / object.width * 100, 2) + '%';
|
||||
}
|
||||
else if (prop === 'y1' || prop === 'y2') {
|
||||
options[prop] = fabric.util.toFixed((options[prop] - object.origY) / object.height * 100, 2) + '%';
|
||||
options[prop] = fabric.util.toFixed((options[prop] - object.fill.origY) / object.height * 100, 2) + '%';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue