mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Add CompoundPath docs.
This commit is contained in:
parent
7ffd8445b7
commit
ae6606e11c
1 changed files with 39 additions and 1 deletions
|
@ -15,6 +15,22 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var CompoundPath = this.CompoundPath = PathItem.extend({
|
var CompoundPath = this.CompoundPath = PathItem.extend({
|
||||||
|
/** @lends CompoundPath# */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new compound path item and places it in the active layer.
|
||||||
|
*
|
||||||
|
* @constructs CompoundPath
|
||||||
|
* @param {Array} [paths] the paths that will be contained within the
|
||||||
|
* compound path.
|
||||||
|
*
|
||||||
|
* @class A compound path contains two or more paths, holes are drawn
|
||||||
|
* where the paths overlap. All the paths in a compound path take on the
|
||||||
|
* style of the backmost path.
|
||||||
|
*
|
||||||
|
* @extends PathItem
|
||||||
|
* @extends Item
|
||||||
|
*/
|
||||||
initialize: function(paths) {
|
initialize: function(paths) {
|
||||||
this.base();
|
this.base();
|
||||||
this._children = [];
|
this._children = [];
|
||||||
|
@ -40,7 +56,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend({
|
||||||
* the path is moved outside and the compound path is erased.
|
* the path is moved outside and the compound path is erased.
|
||||||
* Otherwise, the compound path is returned unmodified.
|
* Otherwise, the compound path is returned unmodified.
|
||||||
*
|
*
|
||||||
* @return the simplified compound path.
|
* @return {CompoundPath|Path} the simplified compound path
|
||||||
*/
|
*/
|
||||||
simplify: function() {
|
simplify: function() {
|
||||||
if (this._children.length == 1) {
|
if (this._children.length == 1) {
|
||||||
|
@ -52,6 +68,13 @@ var CompoundPath = this.CompoundPath = PathItem.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smooth bezier curves without changing the amount of segments or their
|
||||||
|
* points, by only smoothing and adjusting their handle points, for both
|
||||||
|
* open ended and closed paths.
|
||||||
|
*
|
||||||
|
* @author Oleg V. Polikarpotchkin
|
||||||
|
*/
|
||||||
smooth: function() {
|
smooth: function() {
|
||||||
for (var i = 0, l = this._children.length; i < l; i++)
|
for (var i = 0, l = this._children.length; i < l; i++)
|
||||||
this._children[i].smooth();
|
this._children[i].smooth();
|
||||||
|
@ -84,22 +107,37 @@ var CompoundPath = this.CompoundPath = PathItem.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
var fields = {
|
var fields = {
|
||||||
|
/** @lends CompoundPath# */
|
||||||
|
|
||||||
|
// DOCS: document moveTo
|
||||||
|
/**
|
||||||
|
* @param {Point} point
|
||||||
|
*/
|
||||||
moveTo: function(point) {
|
moveTo: function(point) {
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
this.appendTop(path);
|
this.appendTop(path);
|
||||||
path.moveTo.apply(path, arguments);
|
path.moveTo.apply(path, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// DOCS: document moveBy
|
||||||
|
/**
|
||||||
|
* @param {Point} point
|
||||||
|
*/
|
||||||
moveBy: function(point) {
|
moveBy: function(point) {
|
||||||
this.moveTo(getCurrentPath(this).getLastSegment()._point.add(
|
this.moveTo(getCurrentPath(this).getLastSegment()._point.add(
|
||||||
Point.read(arguments)));
|
Point.read(arguments)));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the path. If it is closed, Paper.js connects the first and
|
||||||
|
* last segments.
|
||||||
|
*/
|
||||||
closePath: function() {
|
closePath: function() {
|
||||||
getCurrentPath(this).setClosed(true);
|
getCurrentPath(this).setClosed(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// DOCS: document CompoundPath#lineTo, CompoundPath#cubicCurveTo etc
|
||||||
// Redirect all other drawing commands to the current path
|
// Redirect all other drawing commands to the current path
|
||||||
Base.each(['lineTo', 'cubicCurveTo', 'quadraticCurveTo', 'curveTo',
|
Base.each(['lineTo', 'cubicCurveTo', 'quadraticCurveTo', 'curveTo',
|
||||||
'arcTo', 'lineBy', 'curveBy', 'arcBy'], function(key) {
|
'arcTo', 'lineBy', 'curveBy', 'arcBy'], function(key) {
|
||||||
|
|
Loading…
Reference in a new issue