[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
(function(global) {
|
2013-02-04 19:47:02 +00:00
|
|
|
|
2014-02-16 21:36:03 +00:00
|
|
|
'use strict';
|
2013-02-04 19:47:02 +00:00
|
|
|
|
2015-01-18 15:54:35 +00:00
|
|
|
var fabric = global.fabric || (global.fabric = { }),
|
2015-12-08 11:20:45 +00:00
|
|
|
toFixed = fabric.util.toFixed;
|
2013-02-04 19:47:02 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
if (fabric.Shadow) {
|
|
|
|
|
fabric.warn('fabric.Shadow is already defined.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-02-04 19:47:02 +00:00
|
|
|
|
|
|
|
|
/**
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
* Shadow class
|
|
|
|
|
* @class fabric.Shadow
|
2016-04-27 13:54:18 +00:00
|
|
|
* @see {@link http://fabricjs.com/shadows|Shadow demo}
|
2013-10-05 18:21:28 +00:00
|
|
|
* @see {@link fabric.Shadow#initialize} for constructor definition
|
2013-02-04 19:47:02 +00:00
|
|
|
*/
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ {
|
2013-02-04 19:47:02 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
/**
|
|
|
|
|
* Shadow color
|
|
|
|
|
* @type String
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
color: 'rgb(0,0,0)',
|
2013-02-06 22:55:15 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
/**
|
|
|
|
|
* Shadow blur
|
|
|
|
|
* @type Number
|
|
|
|
|
*/
|
|
|
|
|
blur: 0,
|
2013-07-25 17:39:21 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
/**
|
|
|
|
|
* Shadow horizontal offset
|
|
|
|
|
* @type Number
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
offsetX: 0,
|
2013-02-04 19:47:02 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
/**
|
|
|
|
|
* Shadow vertical offset
|
|
|
|
|
* @type Number
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
offsetY: 0,
|
2013-07-25 17:39:21 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
/**
|
|
|
|
|
* Whether the shadow should affect stroke operations
|
|
|
|
|
* @type Boolean
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
affectStroke: false,
|
|
|
|
|
|
2013-10-25 07:04:48 +00:00
|
|
|
/**
|
|
|
|
|
* Indicates whether toObject should include default values
|
|
|
|
|
* @type Boolean
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
includeDefaultValues: true,
|
|
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
2017-08-31 20:33:10 +00:00
|
|
|
* @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. "rgba(0,0,0,0.2) 2px 2px 10px")
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
* @return {fabric.Shadow} thisArg
|
|
|
|
|
*/
|
|
|
|
|
initialize: function(options) {
|
2014-06-24 13:39:31 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
if (typeof options === 'string') {
|
|
|
|
|
options = this._parseShadow(options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var prop in options) {
|
|
|
|
|
this[prop] = options[prop];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.id = fabric.Object.__uid++;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @private
|
|
|
|
|
* @param {String} shadow Shadow value to parse
|
|
|
|
|
* @return {Object} Shadow object with color, offsetX, offsetY and blur
|
|
|
|
|
*/
|
|
|
|
|
_parseShadow: function(shadow) {
|
2014-02-16 21:36:03 +00:00
|
|
|
var shadowStr = shadow.trim(),
|
2016-09-10 13:14:23 +00:00
|
|
|
offsetsAndBlur = fabric.Shadow.reOffsetsAndBlur.exec(shadowStr) || [],
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
color = shadowStr.replace(fabric.Shadow.reOffsetsAndBlur, '') || 'rgb(0,0,0)';
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
color: color.trim(),
|
|
|
|
|
offsetX: parseInt(offsetsAndBlur[1], 10) || 0,
|
|
|
|
|
offsetY: parseInt(offsetsAndBlur[2], 10) || 0,
|
|
|
|
|
blur: parseInt(offsetsAndBlur[3], 10) || 0
|
|
|
|
|
};
|
|
|
|
|
},
|
2013-07-08 10:39:19 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
/**
|
2013-09-05 16:09:34 +00:00
|
|
|
* Returns a string representation of an instance
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
* @see http://www.w3.org/TR/css-text-decor-3/#text-shadow
|
2013-09-05 16:09:34 +00:00
|
|
|
* @return {String} Returns CSS3 text-shadow declaration
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
*/
|
2013-09-05 16:09:34 +00:00
|
|
|
toString: function() {
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/* _TO_SVG_START_ */
|
|
|
|
|
/**
|
|
|
|
|
* Returns SVG representation of a shadow
|
2013-09-17 20:42:58 +00:00
|
|
|
* @param {fabric.Object} object
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
* @return {String} SVG representation of a shadow
|
|
|
|
|
*/
|
|
|
|
|
toSVG: function(object) {
|
2015-12-08 11:20:45 +00:00
|
|
|
var fBoxX = 40, fBoxY = 40, NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS,
|
2015-12-24 15:57:55 +00:00
|
|
|
offset = fabric.util.rotateVector(
|
|
|
|
|
{ x: this.offsetX, y: this.offsetY },
|
|
|
|
|
fabric.util.degreesToRadians(-object.angle)),
|
2018-04-27 23:17:45 +00:00
|
|
|
BLUR_BOX = 20, color = new fabric.Color(this.color);
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
|
2014-10-21 20:50:34 +00:00
|
|
|
if (object.width && object.height) {
|
|
|
|
|
//http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion
|
|
|
|
|
// we add some extra space to filter box to contain the blur ( 20 )
|
2015-12-09 07:16:27 +00:00
|
|
|
fBoxX = toFixed((Math.abs(offset.x) + this.blur) / object.width, NUM_FRACTION_DIGITS) * 100 + BLUR_BOX;
|
|
|
|
|
fBoxY = toFixed((Math.abs(offset.y) + this.blur) / object.height, NUM_FRACTION_DIGITS) * 100 + BLUR_BOX;
|
2014-10-21 20:50:34 +00:00
|
|
|
}
|
2016-03-26 12:41:34 +00:00
|
|
|
if (object.flipX) {
|
|
|
|
|
offset.x *= -1;
|
|
|
|
|
}
|
|
|
|
|
if (object.flipY) {
|
|
|
|
|
offset.y *= -1;
|
|
|
|
|
}
|
2018-04-27 23:17:45 +00:00
|
|
|
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
return (
|
2014-10-21 20:50:34 +00:00
|
|
|
'<filter id="SVGID_' + this.id + '" y="-' + fBoxY + '%" height="' + (100 + 2 * fBoxY) + '%" ' +
|
|
|
|
|
'x="-' + fBoxX + '%" width="' + (100 + 2 * fBoxX) + '%" ' + '>\n' +
|
2015-07-17 11:36:44 +00:00
|
|
|
'\t<feGaussianBlur in="SourceAlpha" stdDeviation="' +
|
2015-12-08 11:20:45 +00:00
|
|
|
toFixed(this.blur ? this.blur / 2 : 0, NUM_FRACTION_DIGITS) + '"></feGaussianBlur>\n' +
|
|
|
|
|
'\t<feOffset dx="' + toFixed(offset.x, NUM_FRACTION_DIGITS) +
|
|
|
|
|
'" dy="' + toFixed(offset.y, NUM_FRACTION_DIGITS) + '" result="oBlur" ></feOffset>\n' +
|
2018-04-27 23:17:45 +00:00
|
|
|
'\t<feFlood flood-color="' + color.toRgb() + '" flood-opacity="' + color.getAlpha() + '"/>\n' +
|
2015-07-17 11:36:44 +00:00
|
|
|
'\t<feComposite in2="oBlur" operator="in" />\n' +
|
2014-10-21 20:50:34 +00:00
|
|
|
'\t<feMerge>\n' +
|
|
|
|
|
'\t\t<feMergeNode></feMergeNode>\n' +
|
|
|
|
|
'\t\t<feMergeNode in="SourceGraphic"></feMergeNode>\n' +
|
|
|
|
|
'\t</feMerge>\n' +
|
|
|
|
|
'</filter>\n');
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
},
|
|
|
|
|
/* _TO_SVG_END_ */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns object representation of a shadow
|
|
|
|
|
* @return {Object} Object representation of a shadow instance
|
|
|
|
|
*/
|
|
|
|
|
toObject: function() {
|
2013-10-25 07:04:48 +00:00
|
|
|
if (this.includeDefaultValues) {
|
|
|
|
|
return {
|
|
|
|
|
color: this.color,
|
|
|
|
|
blur: this.blur,
|
|
|
|
|
offsetX: this.offsetX,
|
2015-10-21 09:38:20 +00:00
|
|
|
offsetY: this.offsetY,
|
2015-10-21 09:10:34 +00:00
|
|
|
affectStroke: this.affectStroke
|
2013-10-25 07:04:48 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
var obj = { }, proto = fabric.Shadow.prototype;
|
2015-10-21 10:58:59 +00:00
|
|
|
|
|
|
|
|
['color', 'blur', 'offsetX', 'offsetY', 'affectStroke'].forEach(function(prop) {
|
|
|
|
|
if (this[prop] !== proto[prop]) {
|
|
|
|
|
obj[prop] = this[prop];
|
|
|
|
|
}
|
|
|
|
|
}, this);
|
|
|
|
|
|
2013-10-25 07:04:48 +00:00
|
|
|
return obj;
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
}
|
|
|
|
|
});
|
2013-07-08 10:39:19 +00:00
|
|
|
|
2013-02-04 19:47:02 +00:00
|
|
|
/**
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
* Regex matching shadow offsetX, offsetY and blur (ex: "2px 2px 10px rgba(0,0,0,0.2)", "rgb(0,255,0) 2px 2px")
|
|
|
|
|
* @static
|
|
|
|
|
* @field
|
|
|
|
|
* @memberOf fabric.Shadow
|
2013-02-04 19:47:02 +00:00
|
|
|
*/
|
2016-09-10 13:14:23 +00:00
|
|
|
// eslint-disable-next-line max-len
|
[BACK_INCOMPAT] `fabric.Text#textShadow` has been removed - new `fabric.Text.shadow` property (type of fabric.Shadow)
[BACK_INCOMPAT] `fabric.BaseBrush`shadow properties are combined into one property => `fabric.BaseBrush.shadow`(shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY no longer exist)
Removed fabric.Text.getText method => is generated with `fabric.util.createAccessors`
`fabric.Shadow` can now initialized with string or object (e.g. '10px 10px 5px rgb(0,0,255)', 'rgb(0,0,255) 10px 10px 5px', {color: 'gb(0,0,255)', offsetX: 10, offsetY: 10, blur: 5})
`fabric.Shadow.getShadow`to get css3 declaration of shadow (String)
`fabric.Object.set('shadow', value)`is now the same as `fabric.Shadow.setShadow(value)`
Add unit tests
2013-09-03 17:11:21 +00:00
|
|
|
fabric.Shadow.reOffsetsAndBlur = /(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/;
|
|
|
|
|
|
|
|
|
|
})(typeof exports !== 'undefined' ? exports : this);
|