2011-06-20 08:56:49 -04:00
|
|
|
/*
|
2013-01-28 21:03:27 -05:00
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
2011-06-20 08:56:49 -04:00
|
|
|
* http://paperjs.org/
|
2011-06-30 06:01:51 -04:00
|
|
|
*
|
2014-01-03 19:47:16 -05:00
|
|
|
* Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
2011-06-30 06:01:51 -04:00
|
|
|
*
|
2011-07-01 06:17:45 -04:00
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
2011-06-20 08:56:49 -04:00
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2011-07-24 19:25:23 -04:00
|
|
|
* @name Style
|
|
|
|
*
|
2013-04-09 19:46:20 -04:00
|
|
|
* @class Style is used for changing the visual styles of items
|
|
|
|
* contained within a Paper.js project and is returned by
|
|
|
|
* {@link Item#style} and {@link Project#currentStyle}.
|
2011-07-24 19:25:23 -04:00
|
|
|
*
|
2013-04-09 19:46:20 -04:00
|
|
|
* All properties of Style are also reflected directly in {@link Item},
|
|
|
|
* i.e.: {@link Item#fillColor}.
|
|
|
|
*
|
|
|
|
* To set multiple style properties in one go, you can pass an object to
|
|
|
|
* {@link Item#style}. This is a convenient way to define a style once and
|
|
|
|
* apply it to a series of items:
|
|
|
|
*
|
2013-04-21 09:36:03 -04:00
|
|
|
* @classexample {@paperscript} // Styling paths
|
2013-04-09 19:46:20 -04:00
|
|
|
*
|
|
|
|
* var path = new Path.Circle(new Point(80, 50), 30);
|
|
|
|
* path.style = {
|
|
|
|
* fillColor: new Color(1, 0, 0),
|
|
|
|
* strokeColor: 'black',
|
|
|
|
* strokeWidth: 5
|
|
|
|
* };
|
|
|
|
*
|
2013-04-21 09:36:03 -04:00
|
|
|
* @classexample {@paperscript} // Styling text items
|
|
|
|
* var text = new PointText(view.center);
|
2013-04-09 19:46:20 -04:00
|
|
|
* text.content = 'Hello world.';
|
|
|
|
* text.style = {
|
2013-12-08 15:12:51 -05:00
|
|
|
* fontFamily: 'Courier New',
|
2013-12-09 04:17:10 -05:00
|
|
|
* fontWeight: 'bold',
|
2013-04-21 09:36:03 -04:00
|
|
|
* fontSize: 20,
|
|
|
|
* fillColor: 'red',
|
|
|
|
* justification: 'center'
|
2013-04-09 19:46:20 -04:00
|
|
|
* };
|
2013-04-21 09:36:03 -04:00
|
|
|
*
|
|
|
|
* @classexample {@paperscript} // Styling groups
|
|
|
|
* var path1 = new Path.Circle({
|
|
|
|
* center: [100, 50],
|
|
|
|
* radius: 30
|
|
|
|
* });
|
|
|
|
*
|
|
|
|
* var path2 = new Path.Rectangle({
|
|
|
|
* from: [170, 20],
|
|
|
|
* to: [230, 80]
|
|
|
|
* });
|
|
|
|
*
|
|
|
|
* var group = new Group(path1, path2);
|
|
|
|
*
|
|
|
|
* // All styles set on a group are automatically
|
|
|
|
* // set on the children of the group:
|
|
|
|
* group.style = {
|
|
|
|
* strokeColor: 'black',
|
|
|
|
* dashArray: [4, 10],
|
|
|
|
* strokeWidth: 4,
|
|
|
|
* strokeCap: 'round'
|
|
|
|
* };
|
|
|
|
*
|
2011-06-20 08:56:49 -04:00
|
|
|
*/
|
2013-05-27 15:48:58 -04:00
|
|
|
var Style = Base.extend(new function() {
|
2013-04-09 19:46:20 -04:00
|
|
|
// windingRule / resolution / fillOverprint / strokeOverprint are currently
|
|
|
|
// not supported.
|
2013-10-17 05:40:44 -04:00
|
|
|
var defaults = {
|
|
|
|
// Paths
|
|
|
|
fillColor: undefined,
|
|
|
|
strokeColor: undefined,
|
|
|
|
strokeWidth: 1,
|
|
|
|
strokeCap: 'butt',
|
|
|
|
strokeJoin: 'miter',
|
|
|
|
miterLimit: 10,
|
|
|
|
dashOffset: 0,
|
|
|
|
dashArray: [],
|
2013-10-18 08:54:13 -04:00
|
|
|
windingRule: 'nonzero',
|
2013-10-17 05:40:44 -04:00
|
|
|
// Shadows
|
|
|
|
shadowColor: undefined,
|
|
|
|
shadowBlur: 0,
|
|
|
|
shadowOffset: new Point(),
|
|
|
|
// Selection
|
|
|
|
selectedColor: undefined,
|
|
|
|
// Characters
|
2013-12-08 15:12:51 -05:00
|
|
|
fontFamily: 'sans-serif',
|
|
|
|
fontWeight: 'normal',
|
2013-10-17 05:40:44 -04:00
|
|
|
fontSize: 12,
|
2013-12-09 09:15:10 -05:00
|
|
|
font: 'sans-serif', // deprecated, links to fontFamily
|
2013-10-17 05:40:44 -04:00
|
|
|
leading: null,
|
|
|
|
// Paragraphs
|
|
|
|
justification: 'left'
|
|
|
|
};
|
|
|
|
|
|
|
|
var flags = {
|
|
|
|
strokeWidth: /*#=*/ Change.STROKE,
|
|
|
|
strokeCap: /*#=*/ Change.STROKE,
|
|
|
|
strokeJoin: /*#=*/ Change.STROKE,
|
|
|
|
miterLimit: /*#=*/ Change.STROKE,
|
2013-12-08 15:12:51 -05:00
|
|
|
fontFamily: /*#=*/ Change.GEOMETRY,
|
|
|
|
fontWeight: /*#=*/ Change.GEOMETRY,
|
2013-10-17 05:40:44 -04:00
|
|
|
fontSize: /*#=*/ Change.GEOMETRY,
|
2013-12-08 15:12:51 -05:00
|
|
|
font: /*#=*/ Change.GEOMETRY, // deprecated, links to fontFamily
|
2013-10-17 05:40:44 -04:00
|
|
|
leading: /*#=*/ Change.GEOMETRY,
|
|
|
|
justification: /*#=*/ Change.GEOMETRY
|
|
|
|
};
|
|
|
|
|
|
|
|
var item = {},
|
2013-04-09 19:46:20 -04:00
|
|
|
fields = {
|
2013-04-19 22:31:29 -04:00
|
|
|
_defaults: defaults,
|
|
|
|
// Override default fillColor for text items
|
2013-11-28 16:20:00 -05:00
|
|
|
_textDefaults: new Base(defaults, {
|
2013-04-19 22:39:05 -04:00
|
|
|
fillColor: new Color() // black
|
2013-04-19 22:31:29 -04:00
|
|
|
})
|
2013-10-17 05:40:44 -04:00
|
|
|
};
|
2013-04-09 19:46:20 -04:00
|
|
|
|
|
|
|
Base.each(defaults, function(value, key) {
|
|
|
|
var isColor = /Color$/.test(key),
|
|
|
|
part = Base.capitalize(key),
|
2013-04-19 22:31:29 -04:00
|
|
|
flag = flags[key],
|
2013-04-09 19:46:20 -04:00
|
|
|
set = 'set' + part,
|
|
|
|
get = 'get' + part;
|
|
|
|
|
2013-04-19 22:51:04 -04:00
|
|
|
// Define getters and setters to be injected into this class.
|
|
|
|
// This is how style values are handled:
|
|
|
|
// - Style values are all stored in this._values
|
|
|
|
// - The style object starts with an empty _values object, with fallback
|
|
|
|
// on _defaults through code in the getter below.
|
|
|
|
// - Only the styles that are explicitely set on the object get defined
|
|
|
|
// in _values.
|
|
|
|
// - Color values are not stored as converted colors immediately. The
|
|
|
|
// raw value is stored, and conversion only happens in the getter.
|
2013-04-09 19:46:20 -04:00
|
|
|
fields[set] = function(value) {
|
|
|
|
var children = this._item && this._item._children;
|
|
|
|
// Only unify styles on children of Groups, excluding CompoundPaths.
|
|
|
|
if (children && children.length > 0
|
|
|
|
&& this._item._type !== 'compound-path') {
|
|
|
|
for (var i = 0, l = children.length; i < l; i++)
|
|
|
|
children[i]._style[set](value);
|
|
|
|
} else {
|
2013-04-19 22:31:29 -04:00
|
|
|
var old = this._values[key];
|
2013-04-19 22:51:04 -04:00
|
|
|
if (old != value) {
|
2013-04-09 19:46:20 -04:00
|
|
|
if (isColor) {
|
|
|
|
if (old)
|
|
|
|
delete old._owner;
|
2013-10-29 20:25:13 -04:00
|
|
|
if (value && value.constructor === Color) {
|
|
|
|
// Clone color if it already has an owner.
|
|
|
|
// NOTE: If value is not a Color, it is only
|
|
|
|
// converted and cloned in the getter further down.
|
|
|
|
if (value._owner)
|
|
|
|
value = value.clone();
|
2013-04-09 19:46:20 -04:00
|
|
|
value._owner = this._item;
|
2013-10-29 20:25:13 -04:00
|
|
|
}
|
2013-04-09 19:46:20 -04:00
|
|
|
}
|
2013-04-19 22:51:04 -04:00
|
|
|
// Note: We do not convert the values to Colors in the
|
|
|
|
// setter. This only happens once the getter is called.
|
2013-04-19 22:31:29 -04:00
|
|
|
this._values[key] = value;
|
2013-04-09 19:46:20 -04:00
|
|
|
// Notify the item of the style change STYLE is always set,
|
2013-04-19 22:31:29 -04:00
|
|
|
// additional flags come from flags, as used for STROKE:
|
2013-04-09 19:46:20 -04:00
|
|
|
if (this._item)
|
2013-04-19 22:31:29 -04:00
|
|
|
this._item._changed(flag || /*#=*/ Change.STYLE);
|
2013-04-09 19:46:20 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-05-13 21:57:17 -04:00
|
|
|
fields[get] = function(/* dontMerge */) {
|
2013-04-19 22:31:29 -04:00
|
|
|
var value,
|
2013-04-09 19:46:20 -04:00
|
|
|
children = this._item && this._item._children;
|
|
|
|
// If this item has children, walk through all of them and see if
|
|
|
|
// they all have the same style.
|
2013-05-13 21:57:17 -04:00
|
|
|
// If true is passed for dontMerge, don't merge children styles
|
|
|
|
if (!children || children.length === 0 || arguments[0]
|
2013-12-09 09:04:44 -05:00
|
|
|
|| this._item instanceof CompoundPath) {
|
2013-04-19 22:31:29 -04:00
|
|
|
var value = this._values[key];
|
|
|
|
if (value === undefined) {
|
|
|
|
value = this._defaults[key];
|
|
|
|
if (value && value.clone)
|
|
|
|
value = value.clone();
|
|
|
|
this._values[key] = value;
|
2013-04-19 22:51:04 -04:00
|
|
|
} else if (isColor && !(value && value.constructor === Color)) {
|
|
|
|
// Convert to a Color and stored result of conversion.
|
|
|
|
this._values[key] = value = Color.read(
|
2013-06-28 10:37:03 -04:00
|
|
|
[value], 0, 0, { readNull: true, clone: true });
|
2013-04-19 22:31:29 -04:00
|
|
|
if (value)
|
|
|
|
value._owner = this._item;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
2013-04-09 19:46:20 -04:00
|
|
|
for (var i = 0, l = children.length; i < l; i++) {
|
2013-04-19 22:31:29 -04:00
|
|
|
var childValue = children[i]._style[get]();
|
2013-06-11 16:57:28 -04:00
|
|
|
if (i === 0) {
|
2013-04-19 22:31:29 -04:00
|
|
|
value = childValue;
|
|
|
|
} else if (!Base.equals(value, childValue)) {
|
2013-04-09 19:46:20 -04:00
|
|
|
// If there is another item with a different
|
|
|
|
// style, the style is not defined:
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
}
|
2013-04-19 22:31:29 -04:00
|
|
|
return value;
|
2013-04-09 19:46:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Inject style getters and setters into the Item class, which redirect
|
|
|
|
// calls to the linked style object.
|
|
|
|
item[get] = function() {
|
|
|
|
return this._style[get]();
|
|
|
|
};
|
|
|
|
|
|
|
|
item[set] = function(value) {
|
|
|
|
this._style[set](value);
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
Item.inject(item);
|
|
|
|
return fields;
|
|
|
|
}, /** @lends Style# */{
|
2013-06-23 23:18:32 -04:00
|
|
|
_class: 'Style',
|
|
|
|
|
2013-06-12 20:30:35 -04:00
|
|
|
initialize: function Style(style, _item) {
|
2013-04-19 22:51:04 -04:00
|
|
|
// We keep values in a separate object that we can iterate over.
|
2013-04-19 22:31:29 -04:00
|
|
|
this._values = {};
|
2013-06-12 20:30:35 -04:00
|
|
|
this._item = _item;
|
|
|
|
if (_item instanceof TextItem)
|
2013-04-19 22:31:29 -04:00
|
|
|
this._defaults = this._textDefaults;
|
2013-06-12 20:30:35 -04:00
|
|
|
if (style)
|
|
|
|
this.set(style);
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function(style) {
|
|
|
|
// If the passed style object is also a Style, clone its clonable
|
|
|
|
// fields rather than simply copying them.
|
|
|
|
var isStyle = style instanceof Style,
|
|
|
|
// Use the other stlyle's _values object for iteration
|
|
|
|
values = isStyle ? style._values : style;
|
|
|
|
if (values) {
|
2013-04-19 22:31:29 -04:00
|
|
|
for (var key in values) {
|
|
|
|
if (key in this._defaults) {
|
|
|
|
var value = values[key];
|
|
|
|
// Delegate to setter, so Group styles work too.
|
|
|
|
this[key] = value && isStyle && value.clone
|
|
|
|
? value.clone() : value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-20 09:10:37 -04:00
|
|
|
},
|
|
|
|
|
2013-10-17 07:08:54 -04:00
|
|
|
equals: function(style) {
|
|
|
|
return style === this || style && this._class === style._class
|
|
|
|
&& Base.equals(this._values, style._values)
|
|
|
|
|| false;
|
|
|
|
},
|
|
|
|
|
2013-10-29 15:05:39 -04:00
|
|
|
// DOCS: Style#hasFill()
|
|
|
|
hasFill: function() {
|
|
|
|
return !!this.getFillColor();
|
|
|
|
},
|
|
|
|
|
|
|
|
// DOCS: Style#hasStroke()
|
|
|
|
hasStroke: function() {
|
|
|
|
return !!this.getStrokeColor() && this.getStrokeWidth() > 0;
|
|
|
|
},
|
|
|
|
|
2013-10-29 19:00:04 -04:00
|
|
|
// DOCS: Style#hasShadow()
|
|
|
|
hasShadow: function() {
|
|
|
|
return !!this.getShadowColor() && this.getShadowBlur() > 0;
|
|
|
|
},
|
|
|
|
|
2013-10-29 15:05:39 -04:00
|
|
|
// Overrides
|
|
|
|
|
2013-04-09 19:46:20 -04:00
|
|
|
getFontStyle: function() {
|
2013-04-19 22:31:29 -04:00
|
|
|
var size = this.getFontSize();
|
2013-10-10 08:47:27 -04:00
|
|
|
// To prevent an obscure iOS 7 crash, we have to convert the size to a
|
|
|
|
// string first before passing it to the regular expression.
|
|
|
|
// This nonsensical statement would also prevent the bug, prooving that
|
|
|
|
// the issue is not the regular expression itself, but something deeper
|
|
|
|
// down in the optimizer: if (size === 0) size = 0;
|
2013-12-08 15:12:51 -05:00
|
|
|
return this.getFontWeight()
|
|
|
|
+ ' ' + size + (/[a-z]/i.test(size + '') ? ' ' : 'px ')
|
|
|
|
+ this.getFontFamily();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @deprecated use {@link #getFontFamily()} instead.
|
|
|
|
*/
|
|
|
|
getFont: '#getFontFamily',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @deprecated use {@link #setFontFamily(font)} instead.
|
|
|
|
*/
|
|
|
|
setFont: '#setFontFamily',
|
|
|
|
|
|
|
|
getLeading: function getLeading() {
|
|
|
|
// Override leading to return fontSize * 1.2 by default.
|
|
|
|
var leading = getLeading.base.call(this);
|
|
|
|
return leading != null ? leading : this.getFontSize() * 1.2;
|
2013-06-12 20:42:38 -04:00
|
|
|
}
|
2013-04-09 19:46:20 -04:00
|
|
|
|
|
|
|
// DOCS: why isn't the example code showing up?
|
|
|
|
/**
|
|
|
|
* Style objects don't need to be created directly. Just pass an object to
|
|
|
|
* {@link Item#style} or {@link Project#currentStyle}, it will be converted
|
|
|
|
* to a Style object internally.
|
|
|
|
*
|
|
|
|
* @name Style#initialize
|
2013-07-02 15:22:45 -04:00
|
|
|
* @param {Object} style
|
2013-04-09 19:46:20 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@grouptitle Stroke Style}
|
|
|
|
*
|
|
|
|
* The color of the stroke.
|
|
|
|
*
|
|
|
|
* @name Style#strokeColor
|
|
|
|
* @property
|
|
|
|
* @type Color
|
|
|
|
*
|
|
|
|
* @example {@paperscript}
|
|
|
|
* // Setting the stroke color of a path:
|
|
|
|
*
|
|
|
|
* // Create a circle shaped path at { x: 80, y: 50 }
|
|
|
|
* // with a radius of 35:
|
|
|
|
* var circle = new Path.Circle(new Point(80, 50), 35);
|
|
|
|
*
|
|
|
|
* // Set its stroke color to RGB red:
|
|
|
|
* circle.strokeColor = new Color(1, 0, 0);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The width of the stroke.
|
|
|
|
*
|
|
|
|
* @name Style#strokeWidth
|
|
|
|
* @property
|
|
|
|
* @default 1
|
|
|
|
* @type Number
|
|
|
|
*
|
|
|
|
* @example {@paperscript}
|
|
|
|
* // Setting an item's stroke width:
|
|
|
|
*
|
|
|
|
* // Create a circle shaped path at { x: 80, y: 50 }
|
|
|
|
* // with a radius of 35:
|
|
|
|
* var circle = new Path.Circle(new Point(80, 50), 35);
|
|
|
|
*
|
|
|
|
* // Set its stroke color to black:
|
|
|
|
* circle.strokeColor = 'black';
|
|
|
|
*
|
|
|
|
* // Set its stroke width to 10:
|
|
|
|
* circle.strokeWidth = 10;
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The shape to be used at the end of open {@link Path} items, when they
|
|
|
|
* have a stroke.
|
|
|
|
*
|
|
|
|
* @name Style#strokeCap
|
|
|
|
* @property
|
|
|
|
* @default 'butt'
|
|
|
|
* @type String('round', 'square', 'butt')
|
|
|
|
*
|
|
|
|
* @example {@paperscript height=200}
|
|
|
|
* // A look at the different stroke caps:
|
|
|
|
*
|
|
|
|
* var line = new Path(new Point(80, 50), new Point(420, 50));
|
|
|
|
* line.strokeColor = 'black';
|
|
|
|
* line.strokeWidth = 20;
|
|
|
|
*
|
|
|
|
* // Select the path, so we can see where the stroke is formed:
|
|
|
|
* line.selected = true;
|
|
|
|
*
|
|
|
|
* // Set the stroke cap of the line to be round:
|
|
|
|
* line.strokeCap = 'round';
|
|
|
|
*
|
|
|
|
* // Copy the path and set its stroke cap to be square:
|
|
|
|
* var line2 = line.clone();
|
|
|
|
* line2.position.y += 50;
|
|
|
|
* line2.strokeCap = 'square';
|
|
|
|
*
|
|
|
|
* // Make another copy and set its stroke cap to be butt:
|
|
|
|
* var line2 = line.clone();
|
|
|
|
* line2.position.y += 100;
|
|
|
|
* line2.strokeCap = 'butt';
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The shape to be used at the corners of paths when they have a stroke.
|
|
|
|
*
|
|
|
|
* @name Style#strokeJoin
|
|
|
|
* @property
|
|
|
|
* @default 'miter'
|
|
|
|
* @type String('miter', 'round', 'bevel')
|
|
|
|
*
|
|
|
|
* @example {@paperscript height=120}
|
|
|
|
* // A look at the different stroke joins:
|
|
|
|
* var path = new Path();
|
|
|
|
* path.add(new Point(80, 100));
|
|
|
|
* path.add(new Point(120, 40));
|
|
|
|
* path.add(new Point(160, 100));
|
|
|
|
* path.strokeColor = 'black';
|
|
|
|
* path.strokeWidth = 20;
|
|
|
|
*
|
|
|
|
* // Select the path, so we can see where the stroke is formed:
|
|
|
|
* path.selected = true;
|
|
|
|
*
|
|
|
|
* var path2 = path.clone();
|
|
|
|
* path2.position.x += path2.bounds.width * 1.5;
|
|
|
|
* path2.strokeJoin = 'round';
|
|
|
|
*
|
|
|
|
* var path3 = path2.clone();
|
|
|
|
* path3.position.x += path3.bounds.width * 1.5;
|
|
|
|
* path3.strokeJoin = 'bevel';
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The dash offset of the stroke.
|
|
|
|
*
|
|
|
|
* @name Style#dashOffset
|
|
|
|
* @property
|
|
|
|
* @default 0
|
|
|
|
* @type Number
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies an array containing the dash and gap lengths of the stroke.
|
|
|
|
*
|
|
|
|
* @example {@paperscript}
|
|
|
|
* var path = new Path.Circle(new Point(80, 50), 40);
|
|
|
|
* path.strokeWidth = 2;
|
|
|
|
* path.strokeColor = 'black';
|
|
|
|
*
|
|
|
|
* // Set the dashed stroke to [10pt dash, 4pt gap]:
|
|
|
|
* path.dashArray = [10, 4];
|
|
|
|
*
|
|
|
|
* @name Style#dashArray
|
|
|
|
* @property
|
|
|
|
* @default []
|
|
|
|
* @type Array
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The miter limit of the stroke. When two line segments meet at a sharp
|
|
|
|
* angle and miter joins have been specified for {@link #strokeJoin}, it is
|
|
|
|
* possible for the miter to extend far beyond the {@link #strokeWidth} of
|
|
|
|
* the path. The miterLimit imposes a limit on the ratio of the miter length
|
|
|
|
* to the {@link #strokeWidth}.
|
|
|
|
*
|
|
|
|
* @name Style#miterLimit
|
|
|
|
* @property
|
|
|
|
* @default 10
|
|
|
|
* @type Number
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@grouptitle Fill Style}
|
|
|
|
*
|
|
|
|
* The fill color.
|
|
|
|
*
|
|
|
|
* @name Style#fillColor
|
|
|
|
* @property
|
|
|
|
* @type Color
|
|
|
|
*
|
|
|
|
* @example {@paperscript}
|
|
|
|
* // Setting the fill color of a path to red:
|
|
|
|
*
|
|
|
|
* // Create a circle shaped path at { x: 80, y: 50 }
|
|
|
|
* // with a radius of 35:
|
|
|
|
* var circle = new Path.Circle(new Point(80, 50), 35);
|
|
|
|
*
|
|
|
|
* // Set the fill color of the circle to RGB red:
|
|
|
|
* circle.fillColor = new Color(1, 0, 0);
|
|
|
|
*/
|
|
|
|
|
2013-07-19 20:48:29 -04:00
|
|
|
/**
|
|
|
|
* {@grouptitle Shadow Style}
|
|
|
|
*
|
|
|
|
* The shadow color.
|
|
|
|
*
|
|
|
|
* @property
|
|
|
|
* @name Style#shadowColor
|
|
|
|
* @type Color
|
|
|
|
*
|
|
|
|
* @example {@paperscript}
|
2013-09-12 18:30:07 -04:00
|
|
|
* // Creating a circle with a black shadow:
|
|
|
|
*
|
|
|
|
* var circle = new Path.Circle({
|
|
|
|
* center: [80, 50],
|
|
|
|
* radius: 35,
|
|
|
|
* fillColor: 'white',
|
|
|
|
* // Set the shadow color of the circle to RGB black:
|
|
|
|
* shadowColor: new Color(0, 0, 0),
|
|
|
|
* // Set the shadow blur radius to 12:
|
|
|
|
* shadowBlur: 12,
|
|
|
|
* // Offset the shadow by { x: 5, y: 5 }
|
|
|
|
* shadowOffset: new Point(5, 5)
|
|
|
|
* });
|
2013-07-19 20:48:29 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The shadow's blur radius.
|
|
|
|
*
|
|
|
|
* @property
|
|
|
|
* @default 0
|
|
|
|
* @name Style#shadowBlur
|
|
|
|
* @type Number
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The shadow's offset.
|
|
|
|
*
|
|
|
|
* @property
|
|
|
|
* @default 0
|
|
|
|
* @name Style#shadowOffset
|
|
|
|
* @type Point
|
|
|
|
*/
|
|
|
|
|
2013-06-12 17:17:34 -04:00
|
|
|
/**
|
|
|
|
* {@grouptitle Selection Style}
|
|
|
|
*
|
|
|
|
* The color the item is highlighted with when selected. If the item does
|
|
|
|
* not specify its own color, the color defined by its layer is used instead.
|
|
|
|
*
|
|
|
|
* @name Style#selectedColor
|
|
|
|
* @property
|
|
|
|
* @type Color
|
|
|
|
*/
|
|
|
|
|
2013-04-09 19:46:20 -04:00
|
|
|
/**
|
|
|
|
* {@grouptitle Character Style}
|
|
|
|
*
|
2013-12-08 15:12:51 -05:00
|
|
|
* The font-family to be used in text content.
|
2013-04-09 19:46:20 -04:00
|
|
|
*
|
2013-12-08 15:12:51 -05:00
|
|
|
* @name Style#fontFamily
|
2013-04-09 19:46:20 -04:00
|
|
|
* @default 'sans-serif'
|
|
|
|
* @type String
|
|
|
|
*/
|
|
|
|
|
2013-12-08 15:12:51 -05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* The font-weight to be used in text content.
|
|
|
|
*
|
|
|
|
* @name Style#fontWeight
|
|
|
|
* @default 'normal'
|
2013-12-09 04:17:10 -05:00
|
|
|
* @type String|Number
|
2013-12-08 15:12:51 -05:00
|
|
|
*/
|
|
|
|
|
2013-04-09 19:46:20 -04:00
|
|
|
/**
|
|
|
|
* The font size of text content, as {@Number} in pixels, or as {@String}
|
|
|
|
* with optional units {@code 'px'}, {@code 'pt'} and {@code 'em'}.
|
|
|
|
*
|
|
|
|
* @name Style#fontSize
|
|
|
|
* @default 10
|
|
|
|
* @type Number|String
|
|
|
|
*/
|
|
|
|
|
2013-12-08 15:12:51 -05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* The font-family to be used in text content, as one {@String}.
|
|
|
|
* @deprecated use {@link #fontFamily} instead.
|
|
|
|
*
|
|
|
|
* @name Style#font
|
|
|
|
* @default 'sans-serif'
|
|
|
|
* @type String
|
|
|
|
*/
|
|
|
|
|
2013-04-09 19:46:20 -04:00
|
|
|
/**
|
|
|
|
* The text leading of text content.
|
|
|
|
*
|
|
|
|
* @name Style#leading
|
|
|
|
* @default fontSize * 1.2
|
|
|
|
* @type Number|String
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-04-09 20:08:09 -04:00
|
|
|
* {@grouptitle Paragraph Style}
|
2013-04-09 19:46:20 -04:00
|
|
|
*
|
|
|
|
* The justification of text paragraphs.
|
|
|
|
*
|
|
|
|
* @name Style#justification
|
|
|
|
* @default 'left'
|
|
|
|
* @type String('left', 'right', 'center')
|
|
|
|
*/
|
2011-06-20 08:56:49 -04:00
|
|
|
});
|