diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index 4ca14d59..69aacea8 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -450,7 +450,7 @@ var Matrix = Base.extend({ } return this; }, - + /** * Applies this matrix to the specified Canvas Context. */ diff --git a/src/color/Color.js b/src/color/Color.js index dde90634..799f3566 100644 --- a/src/color/Color.js +++ b/src/color/Color.js @@ -8,7 +8,7 @@ var Color = Base.extend({ getAlpha: function() { return this._alpha; }, - + setAlpha: function(alpha) { if (this._alpha == null || alpha == -1) this._alpha = -1; else if (this._alpha < 0) this._alpha = 0; @@ -16,7 +16,7 @@ var Color = Base.extend({ else this._alpha = alpha; this._cssString = null; }, - + /** * Checks if the color has an alpha value. * @@ -25,11 +25,11 @@ var Color = Base.extend({ hasAlpha: function() { return this._alpha != -1; }, - + getCanvasStyle: function() { return this.cssString; }, - + statics: { read: function(args, index, length) { var index = index || 0, length = length || args.length - index; diff --git a/src/color/Gradient.js b/src/color/Gradient.js index d3cc1619..4c267d33 100644 --- a/src/color/Gradient.js +++ b/src/color/Gradient.js @@ -1,16 +1,19 @@ var Gradient = Base.extend({ initialize: function() { - this.stops = [new GradientStop('white', 0), new GradientStop('black', 1)]; + this.stops = [ + new GradientStop('white', 0), + new GradientStop('black', 1)]; this.type = 'linear'; }, - + getStops: function() { return this._stops; }, - + setStops: function(stops) { if (stops.length < 2) - throw new Error('Gradient stop list needs to contain at least two stops.'); + throw new Error( + 'Gradient stop list needs to contain at least two stops.'); this._stops = stops; } }); diff --git a/src/color/GradientColor.js b/src/color/GradientColor.js index 08dcba90..edf49e06 100644 --- a/src/color/GradientColor.js +++ b/src/color/GradientColor.js @@ -8,40 +8,41 @@ var GradientColor = Color.extend({ if (hilite) this.hilite = hilite; }, - + getOrigin: function() { return this._origin; }, - + setOrigin: function() { this._origin = Point.read(arguments); if (this._destination) this._radius = this._destination.getDistance(this._origin); }, - + getDestination: function() { return this._destination; }, - + setDestination: function() { this._destination = Point.read(arguments); this._radius = this._destination.getDistance(this._origin); }, - + getHilite: function() { return this._hilite; }, - + setHilite: function() { var hilite = Point.read(arguments); var vector = hilite.subtract(this.origin); if (vector.length > this._radius) { - this._hilite = this.origin.add(vector.normalize(this._radius - 0.1)); + this._hilite = this.origin.add(vector.normalize( + this._radius - 0.1)); } else { this._hilite = hilite; } }, - + getCanvasStyle: function(ctx) { var gradient; if (this.gradient.type == 'linear') { diff --git a/src/color/GradientStop.js b/src/color/GradientStop.js index 21c0944f..d41f03f3 100644 --- a/src/color/GradientStop.js +++ b/src/color/GradientStop.js @@ -6,19 +6,19 @@ var GradientStop = Base.extend({ this._color = Color.read([color]); this._rampPoint = rampPoint !== null ? rampPoint : 0; }, - + getRampPoint: function() { return this._rampPoint; }, - + setRampPoint: function(rampPoint) { this._rampPoint = rampPoint; }, - + getColor: function() { return this._color; }, - + setColor: function() { this._color = Color.read(arguments); } diff --git a/src/color/GrayColor.js b/src/color/GrayColor.js index e8aa289e..972eca5b 100644 --- a/src/color/GrayColor.js +++ b/src/color/GrayColor.js @@ -21,19 +21,20 @@ var GrayColor = Color.extend({ getComponents: function() { return [this._gray, this._alpha]; }, - + /** - * A value between 0 and 1 that specifies the amount of gray in the gray color. + * A value between 0 and 1 that specifies the amount of gray in the gray + * color. */ getGray: function() { return this._gray; }, - + setGray: function(gray) { this._cssString = null; this._gray = gray; }, - + /** * Checks if the component color values of the GrayColor are the * same as those of the supplied one. @@ -48,13 +49,13 @@ var GrayColor = Color.extend({ } return false; }, - + toString: function() { return '{ gray: ' + this.gray + (this.alpha != -1 ? ', alpha: ' + this.alpha : '') + ' }'; }, - + toCssString: function() { if (!this._cssString) { var component = Math.round((1 - this.gray) * 255) + ','; @@ -67,7 +68,7 @@ var GrayColor = Color.extend({ } }, new function() { var fields = { beans: true }; - + // Using the standard NTSC conversion formula that is used for // calculating the effective luminance of an RGB color: // http://www.mathworks.com/support/solutions/en/data/1-1ASCU/index.html?solution=1-1ASCU diff --git a/src/color/RGBColor.js b/src/color/RGBColor.js index 6eab5869..e94cfb12 100644 --- a/src/color/RGBColor.js +++ b/src/color/RGBColor.js @@ -1,49 +1,52 @@ var RGBColor = Color.extend(new function() { // TODO: convert hex codes to [r,g,b]? var namedColors = { - lightpink: 'FFB6C1', pink: 'FFC0CB', crimson: 'DC143C', - lavenderblush: 'FFF0F5', palevioletred: 'DB7093', hotpink: 'FF69B4', - deeppink: 'FF1493', mediumvioletred: 'C71585', orchid: 'DA70D6', - thistle: 'D8BFD8', plum: 'DDA0DD', violet: 'EE82EE', fuchsia: 'FF00FF', - darkmagenta: '8B008B', purple: '800080', mediumorchid: 'BA55D3', - darkviolet: '9400D3', darkorchid: '9932CC', indigo: '4B0082', - blueviolet: '8A2BE2', mediumpurple: '9370DB', mediumslateblue: '7B68EE', - slateblue: '6A5ACD', darkslateblue: '483D8B', ghostwhite: 'F8F8FF', - lavender: 'E6E6FA', blue: '0000FF', mediumblue: '0000CD', - darkblue: '00008B', navy: '000080', midnightblue: '191970', - royalblue: '4169E1', cornflowerblue: '6495ED', lightsteelblue: 'B0C4DE', - lightslategray: '778899', slategray: '708090', dodgerblue: '1E90FF', - aliceblue: 'F0F8FF', steelblue: '4682B4', lightskyblue: '87CEFA', - skyblue: '87CEEB', deepskyblue: '00BFFF', lightblue: 'ADD8E6', - powderblue: 'B0E0E6', cadetblue: '5F9EA0', darkturquoise: '00CED1', - azure: 'F0FFFF', lightcyan: 'E0FFFF', paleturquoise: 'AFEEEE', - aqua: '00FFFF', darkcyan: '008B8B', teal: '008080', darkslategray: '2F4F4F', - mediumturquoise: '48D1CC', lightseagreen: '20B2AA', turquoise: '40E0D0', - aquamarine: '7FFFD4', mediumaquamarine: '66CDAA', mediumspringgreen: '00FA9A', - mintcream: 'F5FFFA', springgreen: '00FF7F', mediumseagreen: '3CB371', - seagreen: '2E8B57', honeydew: 'F0FFF0', darkseagreen: '8FBC8F', - palegreen: '98FB98', lightgreen: '90EE90', limegreen: '32CD32', - lime: '00FF00', forestgreen: '228B22', green: '008000', darkgreen: '006400', - lawngreen: '7CFC00', chartreuse: '7FFF00', greenyellow: 'ADFF2F', - darkolivegreen: '556B2F', yellowgreen: '9ACD32', olivedrab: '6B8E23', - ivory: 'FFFFF0', beige: 'F5F5DC', lightyellow: 'FFFFE0', - lightgoldenrodyellow: 'FAFAD2', yellow: 'FFFF00', olive: '808000', - darkkhaki: 'BDB76B', palegoldenrod: 'EEE8AA', lemonchiffon: 'FFFACD', - khaki: 'F0E68C', gold: 'FFD700', cornsilk: 'FFF8DC', goldenrod: 'DAA520', - darkgoldenrod: 'B8860B', floralwhite: 'FFFAF0', oldlace: 'FDF5E6', - wheat: 'F5DEB3', orange: 'FFA500', moccasin: 'FFE4B5', papayawhip: 'FFEFD5', - blanchedalmond: 'FFEBCD', navajowhite: 'FFDEAD', antiquewhite: 'FAEBD7', - tan: 'D2B48C', burlywood: 'DEB887', darkorange: 'FF8C00', bisque: 'FFE4C4', - linen: 'FAF0E6', peru: 'CD853F', peachpuff: 'FFDAB9', sandybrown: 'F4A460', - chocolate: 'D2691E', saddlebrown: '8B4513', seashell: 'FFF5EE', - sienna: 'A0522D', lightsalmon: 'FFA07A', coral: 'FF7F50', - orangered: 'FF4500', darksalmon: 'E9967A', tomato: 'FF6347', - salmon: 'FA8072', mistyrose: 'FFE4E1', lightcoral: 'F08080', snow: 'FFFAFA', - rosybrown: 'BC8F8F', indianred: 'CD5C5C', red: 'FF0000', brown: 'A52A2A', - firebrick: 'B22222', darkred: '8B0000', maroon: '800000', white: 'FFFFFF', - whitesmoke: 'F5F5F5', gainsboro: 'DCDCDC', lightgrey: 'D3D3D3', - silver: 'C0C0C0', darkgray: 'A9A9A9', gray: '808080', dimgray: '696969', - black: '000000' + lightpink: 'ffb6c1', pink: 'ffc0cb', crimson: 'dc143c', + lavenderblush: 'fff0f5', palevioletred: 'db7093', hotpink: 'ff69b4', + deeppink: 'ff1493', mediumvioletred: 'c71585', orchid: 'da70d6', + thistle: 'd8bfd8', plum: 'dda0dd', violet: 'ee82ee', fuchsia: 'ff00ff', + darkmagenta: '8b008b', purple: '800080', mediumorchid: 'ba55d3', + darkviolet: '9400d3', darkorchid: '9932cc', indigo: '4b0082', + blueviolet: '8a2be2', mediumpurple: '9370db', mediumslateblue: '7b68ee', + slateblue: '6a5acd', darkslateblue: '483d8b', ghostwhite: 'f8f8ff', + lavender: 'e6e6fa', blue: '0000ff', mediumblue: '0000cd', + darkblue: '00008b', navy: '000080', midnightblue: '191970', + royalblue: '4169e1', cornflowerblue: '6495ed', lightsteelblue: 'b0c4de', + lightslategray: '778899', slategray: '708090', dodgerblue: '1e90ff', + aliceblue: 'f0f8ff', steelblue: '4682b4', lightskyblue: '87cefa', + skyblue: '87ceeb', deepskyblue: '00bfff', lightblue: 'add8e6', + powderblue: 'b0e0e6', cadetblue: '5f9ea0', darkturquoise: '00ced1', + azure: 'f0ffff', lightcyan: 'e0ffff', paleturquoise: 'afeeee', + aqua: '00ffff', darkcyan: '008b8b', teal: '008080', + darkslategray: '2f4f4f', mediumturquoise: '48d1cc', + lightseagreen: '20b2aa', turquoise: '40e0d0', aquamarine: '7fffd4', + mediumaquamarine: '66cdaa', mediumspringgreen: '00fa9a', + mintcream: 'f5fffa', springgreen: '00ff7f', mediumseagreen: '3cb371', + seagreen: '2e8b57', honeydew: 'f0fff0', darkseagreen: '8fbc8f', + palegreen: '98fb98', lightgreen: '90ee90', limegreen: '32cd32', + lime: '00ff00', forestgreen: '228b22', green: '008000', + darkgreen: '006400', lawngreen: '7cfc00', chartreuse: '7fff00', + greenyellow: 'adff2f', darkolivegreen: '556b2f', yellowgreen: '9acd32', + olivedrab: '6b8e23', ivory: 'fffff0', beige: 'f5f5dc', + lightyellow: 'ffffe0', lightgoldenrodyellow: 'fafad2', yellow: 'ffff00', + olive: '808000', darkkhaki: 'bdb76b', palegoldenrod: 'eee8aa', + lemonchiffon: 'fffacd', khaki: 'f0e68c', gold: 'ffd700', + cornsilk: 'fff8dc', goldenrod: 'daa520', darkgoldenrod: 'b8860b', + floralwhite: 'fffaf0', oldlace: 'fdf5e6', wheat: 'f5deb3', + orange: 'ffa500', moccasin: 'ffe4b5', papayawhip: 'ffefd5', + blanchedalmond: 'ffebcd', navajowhite: 'ffdead', antiquewhite: 'faebd7', + tan: 'd2b48c', burlywood: 'deb887', darkorange: 'ff8c00', + bisque: 'ffe4c4', linen: 'faf0e6', peru: 'cd853f', peachpuff: 'ffdab9', + sandybrown: 'f4a460', chocolate: 'd2691e', saddlebrown: '8b4513', + seashell: 'fff5ee', sienna: 'a0522d', lightsalmon: 'ffa07a', + coral: 'ff7f50', orangered: 'ff4500', darksalmon: 'e9967a', + tomato: 'ff6347', salmon: 'fa8072', mistyrose: 'ffe4e1', + lightcoral: 'f08080', snow: 'fffafa', rosybrown: 'bc8f8f', + indianred: 'cd5c5c', red: 'ff0000', brown: 'a52a2a', + firebrick: 'b22222', darkred: '8b0000', maroon: '800000', + white: 'ffffff', whitesmoke: 'f5f5f5', gainsboro: 'dcdcdc', + lightgrey: 'd3d3d3', silver: 'c0c0c0', darkgray: 'a9a9a9', + gray: '808080', dimgray: '696969', black: '000000' }; function stringToComponents(string) { @@ -51,7 +54,7 @@ var RGBColor = Color.extend(new function() { ? hexToComponents(string) : namedToComponents(string); }; - + function hexToComponents(string) { var hex = string.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); if (hex.length >= 4) { @@ -69,7 +72,7 @@ var RGBColor = Color.extend(new function() { throw new Error('The named color "' + name + '" does not exist.'); return hex && hexToComponents(hex); }; - + return { beans: true, @@ -113,7 +116,8 @@ var RGBColor = Color.extend(new function() { }, /** - * A value between 0 and 1 that specifies the amount of red in the RGB color. + * A value between 0 and 1 that specifies the amount of red in the RGB + * color. */ getRed: function() { return this._red; @@ -125,7 +129,8 @@ var RGBColor = Color.extend(new function() { }, /** - * A value between 0 and 1 that specifies the amount of green in the RGB color. + * A value between 0 and 1 that specifies the amount of green in the RGB + * color. */ getGreen: function() { return this._green; @@ -137,7 +142,8 @@ var RGBColor = Color.extend(new function() { }, /** - * A value between 0 and 1 that specifies the amount of blue in the RGB color. + * A value between 0 and 1 that specifies the amount of blue in the RGB + * color. */ getBlue: function() { return this._blue; @@ -147,7 +153,7 @@ var RGBColor = Color.extend(new function() { this._cssString = null; this._blue = blue; }, - + getGray: function() { // Using the standard NTSC conversion formula that is used for // calculating the effective luminance of an RGB color: diff --git a/src/document/DocumentView.js b/src/document/DocumentView.js index 40dfcaee..d9628b8e 100644 --- a/src/document/DocumentView.js +++ b/src/document/DocumentView.js @@ -8,12 +8,12 @@ var DocumentView = Base.extend({ this._zoom = 1; this._center = this._bounds.center; }, - + // TODO: test this. getCenter: function() { return this._center; }, - + setCenter: function() { var center = Point.read(arguments); if (center) { @@ -22,11 +22,11 @@ var DocumentView = Base.extend({ this._center = center; } }, - + getZoom: function() { return this._zoom; }, - + setZoom: function(zoom) { // TODO: clamp the view between 1/32 and 64? var mx = new Matrix(); @@ -34,22 +34,22 @@ var DocumentView = Base.extend({ this.transform(mx); this._zoom = zoom; }, - + scrollBy: function() { var point = Point.read(arguments).negate(); var mx = new Matrix().translate(point); this.transform(mx); }, - + getBounds: function() { return this._bounds; }, - + // TODO: // setBounds: function(rect) { // // }, - + // TODO: getInvalidBounds // TODO: invalidate(rect) // TODO: style: artwork / preview / raster / opaque / ink @@ -59,12 +59,12 @@ var DocumentView = Base.extend({ artworkToView: function(point) { return this.matrix.transform(point); }, - + viewToArtwork: function(point) { // TODO: cache the inverse matrix: return this.matrix.createInverse().transform(point); }, - + // TODO: inherit this code somehow? transform: function(matrix, flags) { var width = this.document.bounds.width; diff --git a/src/document/Symbol.js b/src/document/Symbol.js index bfacf58c..f28a44be 100644 --- a/src/document/Symbol.js +++ b/src/document/Symbol.js @@ -16,7 +16,7 @@ var Symbol = Base.extend({ this._definition.removeFromParent(); this._definition.position = new Point(0, 0); } - + // TODO: // remove() }); diff --git a/src/item/Group.js b/src/item/Group.js index e066c0af..97f64a5b 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -10,7 +10,7 @@ var Group = Item.extend({ } this.clipped = false; }, - + getBounds: function() { if (this.children.length) { var rect = this.children[0].bounds; @@ -28,7 +28,7 @@ var Group = Item.extend({ } return new Rectangle(x1, y1, x2 - x1, y2 - y1); }, - + /** * Specifies whether the group item is to be clipped. * When setting to true, the first child in the group is automatically @@ -45,7 +45,7 @@ var Group = Item.extend({ isClipped: function() { return this._clipped; }, - + setClipped: function(clipped) { this._clipped = clipped; var child = this.firstChild; diff --git a/src/item/Item.js b/src/item/Item.js index 11236d5d..9eb6d479 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -29,20 +29,20 @@ var Item = Base.extend({ } return copy; }, - + /** * Clones the item within the same document. * * @return the newly cloned item */ - + clone: function() { return this.copyTo(this.parent); }, - + // TODO: isSelected / setSelected // TODO: isFullySelected / setFullySelected - + /** * Specifies whether the item is locked. * @@ -55,9 +55,9 @@ var Item = Base.extend({ * * @return {@true if the item is locked} */ - + locked: false, - + /** * Specifies whether the item is visible. * @@ -70,9 +70,9 @@ var Item = Base.extend({ * * @return {@true if the item is visible} */ - + visible: true, - + /** * The opacity of the item. * @@ -87,9 +87,9 @@ var Item = Base.extend({ * * @return the opacity of the item as a value between 0 and 1. */ - + opacity: 1, - + /** * The blend mode of the item. * @@ -103,7 +103,7 @@ var Item = Base.extend({ * */ blendMode: 'normal', - + /** * Specifies whether the item is hidden. * @@ -118,15 +118,15 @@ var Item = Base.extend({ * * @jshide */ - + isHidden: function() { return !this.visible; }, - + setHidden: function(hidden) { this.setVisible(!hidden); }, - + /** * Specifies whether the item defines a clip mask. This can only be set on * paths, compound paths, and text frame objects, and only if the item is @@ -145,7 +145,7 @@ var Item = Base.extend({ isClipMask: function() { return this._clipMask; }, - + setClipMask: function(clipMask) { this._clipMask = clipMask; if (this._clipMask) { @@ -153,19 +153,19 @@ var Item = Base.extend({ this.strokeColor = null; } }, - + // TODO: getIsolated / setIsolated (print specific feature) // TODO: get/setKnockout (print specific feature) // TODO get/setAlphaIsShape // TODO: get/setData - + /** * Reverses the order of this item's children */ reverseChildren: function() { this.children.reverse(); }, - + /** * The first item contained within this item. */ @@ -181,7 +181,7 @@ var Item = Base.extend({ if (this.children.length > 0) return this.children[this.children.length - 1]; }, - + /** * The next item on the same level as this item. */ @@ -199,7 +199,7 @@ var Item = Base.extend({ getPreviousSibling: function() { if (this.parent) { var index = this.index - 1; - if (index <= 0) + if (index <= 0) return this.parent.children[index]; } }, @@ -213,7 +213,7 @@ var Item = Base.extend({ // We need linked lists instead. return this.parent.children.indexOf(this); }, - + /** * Removes the item from its parent's children list. */ @@ -222,14 +222,14 @@ var Item = Base.extend({ this.parent.children.splice(this.index, 1); this.parent = null; }, - + /** * Removes the item. - */ + */ remove: function() { this.removeFromParent(); }, - + /** * {@grouptitle Tests} * @@ -240,7 +240,7 @@ var Item = Base.extend({ hasChildren: function() { return this.children && this.children.length; }, - + /** * Checks whether the item is editable. * @@ -256,7 +256,7 @@ var Item = Base.extend({ } return true; }, - + /** * Checks whether the item is valid, i.e. it hasn't been removed. * @@ -271,7 +271,7 @@ var Item = Base.extend({ * @return {@true if the item is valid} */ // TODO: isValid / checkValid - + /** * {@grouptitle Hierarchy Operations} * @@ -295,7 +295,7 @@ var Item = Base.extend({ item.parent = this; item.document = this.document; }, - + /** * Inserts the specified item as a child of this item by appending it to the * list of children and moving it below all other children. You can use this @@ -317,7 +317,7 @@ var Item = Base.extend({ item.parent = this; item.document = this.document; }, - + /** * A link to {@link #appendTop} * @@ -326,7 +326,7 @@ var Item = Base.extend({ appendChild: function(item) { return this.appendTop(item); }, - + /** * Moves this item above the specified item. * @@ -350,7 +350,7 @@ var Item = Base.extend({ this.document = item.document; return true; }, - + /** * Moves the item below the specified item. * @@ -374,7 +374,7 @@ var Item = Base.extend({ this.document = item.document; return true; }, - + /** * {@grouptitle Hierarchy Tests} * @@ -392,7 +392,7 @@ var Item = Base.extend({ * @return {@true if it is above the specified item} */ // TODO: isAbove - + /** * Checks if the item is below the specified item in the stacking order of * the document. @@ -408,16 +408,16 @@ var Item = Base.extend({ * @return {@true if it is below the specified item} */ // TODO: isBelow - + // TODO: this is confusing the beans // isParent: function(item) { // return this.parent == item; // }, - + isChild: function(item) { return item.parent == this; }, - + /** * Checks if the item is contained within the specified item. * @@ -441,7 +441,7 @@ var Item = Base.extend({ } return false; }, - + /** * Checks if the item is an ancestor of the specified item. * @@ -466,7 +466,7 @@ var Item = Base.extend({ } return false; }, - + /** * Checks whether the item is grouped with the specified item. * @@ -487,7 +487,7 @@ var Item = Base.extend({ } return false; }, - + getBounds: function() { // TODO: Implement for items other than paths return new Rectangle(); @@ -515,7 +515,7 @@ var Item = Base.extend({ // Now execute the transformation: this.transform(matrix); }, - + /** * The bounding rectangle of the item including stroke width. */ @@ -525,7 +525,7 @@ var Item = Base.extend({ * The bounding rectangle of the item including stroke width and controls. */ // TODO: getControlBounds - + /** * Rasterizes the item into a newly created Raster object. The item itself * is not removed after rasterization. @@ -552,7 +552,7 @@ var Item = Base.extend({ raster.scale(1 / scale); return raster; }, - + /** * The item's position within the art board. This is the * {@link Rectangle#getCenter()} of the {@link Item#getBounds()} rectangle. @@ -684,7 +684,7 @@ var Item = Base.extend({ } this.transform(new Matrix().shear(shx, shy, center || this.position)); }, - + /** * The path style of the item. * diff --git a/src/item/Layer.js b/src/item/Layer.js index 4eedd4a3..77797eba 100644 --- a/src/item/Layer.js +++ b/src/item/Layer.js @@ -11,7 +11,7 @@ var Layer = Group.extend({ getIndex: function() { return !this.parent ? this.document.layers.indexOf(this) : this.base(); }, - + /** * Removes the layer from its document's layers list * or its parent's children list. @@ -23,7 +23,7 @@ var Layer = Group.extend({ this.base(); } }, - + moveAbove: function(item) { // if the item is a layer and contained within Document#layers if (item instanceof Layer && !item.parent) { @@ -35,7 +35,7 @@ var Layer = Group.extend({ this.base(item); } }, - + moveBelow: function(item) { // if the item is a layer and contained within Document#layers if (item instanceof Layer && !item.parent) { @@ -47,7 +47,7 @@ var Layer = Group.extend({ this.base(item); } }, - + getNextSibling: function() { if (!this.parent) { var index = this.index + 1; @@ -57,7 +57,7 @@ var Layer = Group.extend({ return this.base(); } }, - + getPreviousSibling: function() { if (!this.parent) { var index = this.index - 1; diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index 2cdc242b..37bef352 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -1,6 +1,6 @@ var PlacedSymbol = Item.extend({ beans: true, - + initialize: function() { this.base(); if (arguments[0] instanceof Symbol) { @@ -23,7 +23,7 @@ var PlacedSymbol = Item.extend({ // TODO: should size be cached here, or on Symbol? this._size = this._bounds.size; }, - + _transform: function(matrix, flags) { var width = this._size.width; var height = this._size.height; @@ -36,7 +36,7 @@ var PlacedSymbol = Item.extend({ x, y + height]; this.matrix.preConcatenate(matrix); this.matrix.transform(coords, 0, coords, 0, 4); - + var xMin = coords[0], xMax = coords[0]; var yMin = coords[1], yMax = coords[1]; for (var i = 2; i < 8; i += 2) { @@ -53,7 +53,7 @@ var PlacedSymbol = Item.extend({ bounds.width = xMax - xMin; bounds.height = yMax - yMin; }, - + getBounds: function() { return this._bounds; }, diff --git a/src/item/Raster.js b/src/item/Raster.js index 70ab33df..7a6a3896 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -27,7 +27,7 @@ var Raster = Item.extend({ getSize: function() { return this._size; }, - + setSize: function() { var size = Size.read(arguments); var canvas = CanvasProvider.getCanvas(size); @@ -41,21 +41,21 @@ var Raster = Item.extend({ this._context = null; this._canvas = canvas; }, - + /** * The width of the raster in pixels. */ getWidth: function() { return this._size.width; }, - + /** * The height of the raster in pixels. */ getHeight: function() { return this._size.height; }, - + /** * Pixels per inch of the raster at it's current size. */ @@ -69,7 +69,7 @@ var Raster = Item.extend({ 72 / v.length ); }, - + getSubImage: function(/* rectangle */) { var rectangle = Rectangle.read(arguments); var canvas = CanvasProvider.getCanvas(rectangle.size); @@ -78,11 +78,11 @@ var Raster = Item.extend({ canvas.width, canvas.height, 0, 0, canvas.width, canvas.height); return canvas; }, - + getImage: function() { return this._image || this.canvas; }, - + // TODO: setImage // TODO: drawImage(image, point) @@ -90,7 +90,7 @@ var Raster = Item.extend({ var point = center = Point.read(arguments, 1); this.context.drawImage(image, x, y); }, - + /** * {@grouptitle Pixels} * @@ -107,7 +107,7 @@ var Raster = Item.extend({ channels.push(pixels[i] / 255); return Color.read(channels); }, - + // TODO: setPixel(point, color) setPixel: function(x, y, color) { color = Color.read(arguments, 2); @@ -119,17 +119,17 @@ var Raster = Item.extend({ imageData.data[3] = color.alpha != -1 ? color.alpha * 255 : 255; ctx.putImageData(imageData, x, y); }, - + getContext: function() { if (!this._context) this._context = this.canvas.getContext('2d'); return this._context; }, - + setContext: function(context) { this._context = context; }, - + getCanvas: function() { if (!this._canvas) { this._canvas = CanvasProvider.getCanvas(this.size); @@ -138,7 +138,7 @@ var Raster = Item.extend({ } return this._canvas; }, - + setCanvas: function(canvas) { if (this._canvas) CanvasProvider.returnCanvas(this._canvas); @@ -148,7 +148,7 @@ var Raster = Item.extend({ this._ctx = null; this._canvas = canvas; }, - + _transform: function(matrix, flags) { // In order to set the right context transformation when drawing the // raster, simply preconcatenate the internal matrix with the provided @@ -158,7 +158,7 @@ var Raster = Item.extend({ // extremas that define our raster's bounds, and update them straight // away var width = this._size.width, - height = this._size.height, + height = this._size.height, x = -width / 2, y = -height / 2, coords = [ @@ -180,7 +180,7 @@ var Raster = Item.extend({ } this._bounds.set(min[0], min[1], max[0] - min[0], max[1] - min[1]); }, - + getBounds: function() { return this._bounds; }, @@ -208,7 +208,7 @@ var Raster = Item.extend({ channels[i] /= total; return total ? Color.read(channels) : null; } - + return { /** * {@grouptitle Average Color} @@ -236,7 +236,7 @@ var Raster = Item.extend({ bounds = new Rectangle(object.x - 0.5, object.y - 0.5, 1, 1); } - + var canvas = CanvasProvider.getCanvas(bounds.size); var ctx = canvas.getContext('2d'); var delta = bounds.topLeft.multiply(-1); diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 91dc231f..5ad1d418 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -8,7 +8,7 @@ var CompoundPath = PathItem.extend({ } } }, - + // TODO: have getBounds of Group / Layer / CompoundPath use the same // code (from a utility script?) getBounds: function() { @@ -28,7 +28,7 @@ var CompoundPath = PathItem.extend({ } return new Rectangle(x1, y1, x2 - x1, y2 - y1); }, - + /** * If this is a compound path with only one path inside, * the path is moved outside and the compound path is erased. @@ -45,7 +45,7 @@ var CompoundPath = PathItem.extend({ } return this; }, - + smooth: function() { for (var i = 0, l = this.children.length; i < l; i++) { this.children[i].smooth(); diff --git a/src/path/Path.Constructors.js b/src/path/Path.Constructors.js index a8a9b186..04d204c1 100644 --- a/src/path/Path.Constructors.js +++ b/src/path/Path.Constructors.js @@ -7,7 +7,7 @@ Path.inject({ statics: new function() { new Segment([1, 0.5], [0, -kappa], [0, kappa ]), new Segment([0.5, 1], [kappa, 0 ], [-kappa, 0]) ]; - + return { Line: function() { var path = new Path(); @@ -103,7 +103,7 @@ Path.inject({ statics: new function() { path.arcTo(through, to); return path; }, - + RegularPolygon: function(center, numSides, radius) { center = new Point(center); var path = new Path(); diff --git a/src/path/Path.js b/src/path/Path.js index fee28ae8..7fedf22b 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -166,7 +166,7 @@ var Path = PathItem.extend({ if (segment) this._add(segment); }, - + /** * Adds a cubic bezier curve to the path, defined by two handles and a to * point. @@ -183,7 +183,7 @@ var Path = PathItem.extend({ new Segment(to, handle2.subtract(to), new Point()) ); }, - + /** * Adds a quadratic bezier curve to the path, defined by a handle and a to * point. @@ -203,7 +203,7 @@ var Path = PathItem.extend({ to ); }, - + curveTo: function(through, to, parameter) { through = new Point(through); to = new Point(to); @@ -223,7 +223,7 @@ var Path = PathItem.extend({ + parameter); this.quadraticCurveTo(handle, to); }, - + arcTo: function(to, clockwise) { var through, to; // Get the start point: @@ -240,7 +240,7 @@ var Path = PathItem.extend({ ? middle.subtract(-step.y, step.x) : middle.add(-step.y, step.x); } - + var x1 = current.point.x, x2 = through.x, x3 = to.x; var y1 = current.point.y, y2 = through.y, y3 = to.y; @@ -312,7 +312,7 @@ var Path = PathItem.extend({ angle += inc; } }, - + lineBy: function() { var vector = Point.read(arguments); if (vector) { @@ -320,7 +320,7 @@ var Path = PathItem.extend({ this.lineTo(current.point.add(vector)); } }, - + curveBy: function(throughVector, toVector, parameter) { throughVector = Point.read(throughVector); toVector = Point.read(toVector); @@ -328,7 +328,7 @@ var Path = PathItem.extend({ this.curveTo(current.add(throughVector), current.add(toVector), parameter); }, - + arcBy: function(throughVector, toVector) { throughVector = Point.read(throughVector); toVector = Point.read(toVector); diff --git a/src/path/Segment.js b/src/path/Segment.js index 1f9050ba..4b91d111 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -33,20 +33,20 @@ var Segment = Base.extend({ if (!this.handleOut) this.handleOut = new Point(); }, - + getPoint: function() { return this.point; }, - + setPoint: function() { var point = Point.read(arguments); this.point = point; }, - + getHandleIn: function() { return this.handleIn; }, - + setHandleIn: function() { var point = Point.read(arguments); this.handleIn = point; @@ -55,13 +55,13 @@ var Segment = Base.extend({ getHandleOut: function() { return this.handleOut; }, - + setHandleOut: function() { var point = Point.read(arguments); this.handleOut = point; this.corner = !handleIn.isParallel(handleOut); }, - + getIndex: function() { // TODO: Cache and update indices instead of searching? return this.path._segments.indexOf(this); @@ -70,7 +70,7 @@ var Segment = Base.extend({ getPath: function() { return this._path; }, - + // TODO: // getCurve: function() { // if (this._segments && this._segments.path) { @@ -80,46 +80,46 @@ var Segment = Base.extend({ // return index < curves.length ? curves[index] : null; // } // }, - + getNext: function() { var index = this.index; return this.path && index < this.path._segments.length - 1 ? this.path._segments[index + 1] : null; }, - + getPrevious: function() { return this.path != null && index > 0 ? this.path._segments[this.index - 1] : null; }, - + // TODO: // isSelected: function() { - // + // // } // // setSelected: function(pt, selected) - + reverse: function() { return new Segment(this.point, this.handleOut, this.handleIn); }, - + clone: function() { return new Segment(this); }, - + remove: function() { if (this.path && this.path._segments) return this.path._segments.splice(this.index, 1); return false; }, - + toString: function() { return '{ point: ' + this.point + (this.handleIn ? ', handleIn '+ this.handleIn : '') + (this.handleOut ? ', handleOut ' + this.handleOut : '') + ' }'; }, - + statics: { read: function(args, index, length) { var index = index || 0, length = length || args.length - index; diff --git a/src/tool/Tool.js b/src/tool/Tool.js index cb396085..fc729dee 100644 --- a/src/tool/Tool.js +++ b/src/tool/Tool.js @@ -4,7 +4,7 @@ var Tool = ToolHandler.extend(new function() { // TODO: always the active view? return document.activeView.viewToArtwork(point); }; - + return { beans: true, @@ -27,7 +27,8 @@ var Tool = ToolHandler.extend(new function() { if (that.onMouseDown) that._document.redraw(); if (that.eventInterval != -1) - this.intervalId = setInterval(events.drag, that.eventInterval); + this.intervalId = setInterval(events.drag, + that.eventInterval); dragging = true; }, drag: function(e) { @@ -62,9 +63,9 @@ var Tool = ToolHandler.extend(new function() { /** * The fixed time delay between each call to the {@link #onMouseDrag} - * event. Setting this to an interval means the {@link #onMouseDrag} event - * is called repeatedly after the initial {@link #onMouseDown} until the - * user releases the mouse. + * event. Setting this to an interval means the {@link #onMouseDrag} + * event is called repeatedly after the initial {@link #onMouseDown} + * until the user releases the mouse. * * Sample code: * diff --git a/src/tool/ToolHandler.js b/src/tool/ToolHandler.js index 2fd34072..8d5e311c 100644 --- a/src/tool/ToolHandler.js +++ b/src/tool/ToolHandler.js @@ -12,8 +12,7 @@ var ToolHandler = Base.extend({ this[i] = handlers[i]; } }, - - + /** * The minimum distance the mouse has to drag before firing the onMouseDrag * event, since the last onMouseDrag event. @@ -48,7 +47,8 @@ var ToolHandler = Base.extend({ }, getFixedDistance: function() { - if (this._minDistance != null && this._minDistance.equals(this._maxDistance)) + if (this._minDistance != null + && this._minDistance.equals(this._maxDistance)) return this._minDistance; return null; }, @@ -121,7 +121,8 @@ var ToolHandler = Base.extend({ // would produce weird results. matchMaxDistance controls this. this.matchMaxDistance = false; while (this.updateEvent(type, pt, this.minDistance, - this.maxDistance, false, this.needsChange, this.matchMaxDistance)) { + this.maxDistance, false, this.needsChange, + this.matchMaxDistance)) { if (this.onMouseDrag) this.onMouseDrag(new ToolEvent(this, type, modifiers)); this.needsChange = true; @@ -131,8 +132,9 @@ var ToolHandler = Base.extend({ case 'MOUSE_UP': // If the last mouse drag happened in a different place, call // mouse drag first, then mouse up. - if ((this.point.x != pt.x || this.point.y != pt.y) && this.updateEvent( - 'MOUSE_DRAG', pt, this.minDistance, this.maxDistance, false, false, false)) { + if ((this.point.x != pt.x || this.point.y != pt.y) + && this.updateEvent('MOUSE_DRAG', pt, this.minDistance, + this.maxDistance, false, false, false)) { if (this.onMouseDrag) this.onMouseDrag(new ToolEvent(this, type, modifiers)); } diff --git a/src/util/MathUtils.js b/src/util/MathUtils.js index 966ca4ea..e2721232 100644 --- a/src/util/MathUtils.js +++ b/src/util/MathUtils.js @@ -4,8 +4,8 @@ var MathUtils = { MANT_DIGITS: 53, EPSILON: Math.pow(2, -52), - // Compute a numerical approximation to an integral via adaptive Simpson's Rule - // This routine ignores underflow. + // Compute a numerical approximation to an integral via adaptive Simpson's + // Rule This routine ignores underflow. // Returns approximate value of the integral if successful. // f: Pointer to function to be integrated. @@ -53,10 +53,11 @@ var MathUtils = { if (index >= table.length) success = false; - if (!success || (Math.abs(diff) <= accuracy * Math.abs(area) && da <= dxmax)) { + if (!success || (Math.abs(diff) <= accuracy * Math.abs(area) + && da <= dxmax)) { // Accept approximate integral. - // If it was a right interval, add results to finish at this level. - // If it was a left interval, process right interval. + // If it was a right interval, add results to finish at this + // level. If it was a left interval, process right interval. for (;;) { if (!p.left) { // process right-half interval alpha += da; @@ -76,7 +77,8 @@ var MathUtils = { } } else { - // Raise level and store information for processing right-half interval. + // Raise level and store information for processing right-half + // interval. p = table[++index] = { left: false, f1t: fv2, @@ -145,7 +147,8 @@ var MathUtils = { diff = est - sum; area = parea + sum; var b2 = alpha + da; - if (Math.abs(Math.abs(integral - area) - Math.abs(pdiff)) + Math.abs(diff) <= fv4 * accuracy * (b2 - a)) { + if (Math.abs(Math.abs(integral - area) - Math.abs(pdiff)) + + Math.abs(diff) <= fv4 * accuracy * (b2 - a)) { return { b: b2, area: area }; } if (Math.abs(integral - area) > Math.abs(pdiff + diff)) { @@ -155,10 +158,12 @@ var MathUtils = { p.left = true; p.psum = parea; } else { - if ((Math.abs(diff) <= fv4 * accuracy * da || dx <= dxmin) && da <= dxmax) { + if ((Math.abs(diff) <= fv4 * accuracy * da + || dx <= dxmin) && da <= dxmax) { // Accept approximate integral sum. - // If it was a right interval, add results to finish at this level. - // If it was a left interval, process right interval. + // If it was a right interval, add results to finish + // at this level. If it was a left interval, process + // right interval. pdiff += diff; for (;;) { if (!p.left) { // process right-half interval @@ -193,7 +198,8 @@ var MathUtils = { } if (index >= table.length) return null; - // Raise level and store information for processing right-half interval. + // Raise level and store information for processing right-half + // interval. da = dx; est = estl; p = table[++index] = { diff --git a/src/util/PaperScript.js b/src/util/PaperScript.js index f5f239d5..725e9081 100644 --- a/src/util/PaperScript.js +++ b/src/util/PaperScript.js @@ -1,5 +1,4 @@ var PaperScript = new function() { - // Handle Math Operators var operators = {