From 9ccba17fbefa5a29a3ac359ad3d822caee6e98ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 14 Apr 2014 18:29:26 +0200 Subject: [PATCH] Clean up white-space, comments and jshint errors. --- src/item/Item.js | 10 +++++----- src/item/Raster.js | 2 +- src/path/Curve.js | 10 +++++----- src/path/Path.js | 10 +++++----- src/path/PathFitter.js | 2 +- src/path/PathItem.Boolean.js | 12 ++++++------ src/style/Color.js | 1 - 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 9fbc8fed..136fa8c8 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -2060,7 +2060,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{ // If the item is removed and inserted it again further above, // the index needs to be adjusted accordingly. if (item._parent === this._parent && index > this._index) - index--; + index--; return item._parent.insertChild(index, this, _preserve); }, @@ -2083,8 +2083,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{ * possible. */ insertBelow: function(item, _preserve) { - return this._insert(false, item, _preserve); - }, + return this._insert(false, item, _preserve); + }, /** * Sends this item to the back of all other items within the same parent. @@ -2289,7 +2289,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{ * @return Boolean */ isEmpty: function() { - return !this._children || this._children.length == 0; + return !this._children || this._children.length === 0; }, /** @@ -3029,7 +3029,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{ * {@code event.delta}: the time passed in seconds since the last * frame event. * - * @see View#onFrame + * @see View#onFrame * @example {@paperscript} * // Creating an animation: * diff --git a/src/item/Raster.js b/src/item/Raster.js index 843b071c..2509e661 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -159,7 +159,7 @@ var Raster = Item.extend(/** @lends Raster# */{ }, isEmpty: function() { - return this._size.width == 0 && this._size.height == 0; + return this._size.width === 0 && this._size.height === 0; }, /** diff --git a/src/path/Curve.js b/src/path/Curve.js index 7790ff8b..166460d6 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -1022,7 +1022,7 @@ new function() { // Scope for methods that require numerical integration // Iteratively calculate curve range lengths, and add them up, // using integration precision depending on the size of the // range. This is much faster and also more precise than not - // modifing start and calculating total length each time. + // modifying start and calculating total length each time. function f(t) { var count = getIterations(start, t); length += start < t @@ -1083,7 +1083,7 @@ new function() { // Scope for methods that require numerical integration top = hull[0], bottom = hull[1], tMinClip, tMaxClip; - // Clip the convexhull with dMin and dMax + // Clip the convex-hull with dMin and dMax tMinClip = clipConvexHull(top, bottom, dMin, dMax); top.reverse(); bottom.reverse(); @@ -1169,7 +1169,7 @@ new function() { // Scope for methods that require numerical integration /*#*/ if (__options.fatlineClipping) { /** - * Calculate the convex hull for the non-paramertic bezier curve D(ti, di(t)) + * Calculate the convex hull for the non-parametric bezier curve D(ti, di(t)) * The ti is equally spaced across [0..1] — [0, 1/3, 2/3, 1] for * di(t), [dq0, dq1, dq2, dq3] respectively. In other words our CVs for the * curve are already sorted in the X axis in the increasing order. @@ -1206,7 +1206,7 @@ new function() { // Scope for methods that require numerical integration // p1 and p2 lie on the same sides of [ p0, p3 ]. The hull can be // a triangle or a quadrilateral and line [ p0, p3 ] is part of the // hull. Check if the hull is a triangle or a quadrilateral. - // Also, if atleast one of the distances for p1 or p2, from line + // Also, if at least one of the distances for p1 or p2, from line // [p0, p3] is zero then hull must at most have 3 vertices. var pmax, cross = 0, distZero = dist1 === 0 || dist2 === 0; @@ -1318,7 +1318,7 @@ new function() { // Scope for methods that require numerical integration } var roots = [], count = Curve.solveCubic(rvc, 1, 0, roots, 0, 1); - // NOTE: count could be -1 for inifnite solutions, but that should only + // NOTE: count could be -1 for infinite solutions, but that should only // happen with lines, in which case we should not be here. for (var i = 0; i < count; i++) { var tc = roots[i], diff --git a/src/path/Path.js b/src/path/Path.js index bde74067..23cafc05 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -2384,7 +2384,7 @@ var Path = PathItem.extend(/** @lends Path# */{ 'Cannot create an arc with the given arguments'); center = new Point(rx * y / ry, -ry * x / rx) // "...where the + sign is chosen if fA != fS, - // and the − sign is chosen if fA = fS." + // and the - sign is chosen if fA = fS." .multiply((large === clockwise ? -1 : 1) * Math.sqrt(factor)) .rotate(rotation).add(middle); @@ -2393,7 +2393,7 @@ var Path = PathItem.extend(/** @lends Path# */{ matrix = new Matrix().translate(center).rotate(rotation) .scale(rx, ry); // Transform from and to to the unit circle coordinate space - // and calculcate start vector and extend from there. + // and calculate start vector and extend from there. vector = matrix._inverseTransform(from); extent = vector.getDirectedAngle(matrix._inverseTransform(to)); // "...if fS = 0 and extent is > 0, then subtract 360, whereas @@ -2646,7 +2646,7 @@ statics: { // When both handles are set in a segment and they are collinear, // the join setting is ignored and round is always used. var handleIn = segment._handleIn, - handleOut = segment._handleOut + handleOut = segment._handleOut; if (join === 'round' || !handleIn.isZero() && !handleOut.isZero() && handleIn.isColinear(handleOut)) { addRound(segment); @@ -2770,7 +2770,7 @@ statics: { // or the last segment of the open path, in order to determine in which // direction to move the point. if (cap === 'square') - point = point.add(normal.rotate(loc.getParameter() == 0 ? -90 : 90)); + point = point.add(normal.rotate(loc.getParameter() === 0 ? -90 : 90)); addPoint(point.add(normal)); addPoint(point.subtract(normal)); }, @@ -2792,7 +2792,7 @@ statics: { segment._transformCoordinates(matrix, coords, false); for (var j = 0; j < 6; j += 2) { // Use different padding for points or handles - var padding = j == 0 ? joinPadding : strokePadding, + var padding = j === 0 ? joinPadding : strokePadding, paddingX = padding ? padding[0] : 0, paddingY = padding ? padding[1] : 0, x = coords[j], diff --git a/src/path/PathFitter.js b/src/path/PathFitter.js index 3b1d0d42..a03e88b5 100644 --- a/src/path/PathFitter.js +++ b/src/path/PathFitter.js @@ -202,7 +202,7 @@ var PathFitter = Base.extend({ return u - diff.dot(pt1) / df; }, - // Evaluate a Bezier curve at a particular parameter value + // Evaluate a bezier curve at a particular parameter value evaluate: function(degree, curve, t) { // Copy array var tmp = curve.slice(); diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index 8ae77640..4dde9093 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -82,7 +82,7 @@ PathItem.inject(new function() { collect(_path2._children || [_path2]); // Propagate the winding contribution. Winding contribution of curves // does not change between two intersections. - // First, sort all segments with an intersection to the begining. + // First, sort all segments with an intersection to the beginning. segments.sort(function(a, b) { var _a = a._intersection, _b = b._intersection; @@ -312,7 +312,7 @@ PathItem.inject(new function() { /** * Private method to trace closed contours from a set of segments according - * to a set of constraints—winding contribution and a custom operator. + * to a set of constraints-winding contribution and a custom operator. * * @param {Segment[]} segments Array of 'seed' segments for tracing closed * contours @@ -440,11 +440,11 @@ PathItem.inject(new function() { * Returns the winding contribution of the given point with respect to * this PathItem. * - * @param {Point} point the location for which to determine the winding + * @param {Point} point the location for which to determine the winding * direction - * @param {Boolean} horizontal whether we need to consider this point - * as part of a horizontal curve - * @param {Boolean} testContains whether we need to consider this point + * @param {Boolean} horizontal whether we need to consider this point as + * part of a horizontal curve + * @param {Boolean} testContains whether we need to consider this point * as part of stationary points on the curve itself, used when checking * the winding about a point. * @return {Number} the winding number diff --git a/src/style/Color.js b/src/style/Color.js index 5520ff63..a36808d1 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -41,7 +41,6 @@ * circle.fillColor = '#ff0000'; */ var Color = Base.extend(new function() { - var types = { gray: ['gray'], rgb: ['red', 'green', 'blue'],