mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Prebuilt module for commit b59baeb9aa
This commit is contained in:
parent
a00e1ec1e6
commit
03b457116e
6 changed files with 112 additions and 46 deletions
27
dist/docs/assets/js/paper.js
vendored
27
dist/docs/assets/js/paper.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Sun Dec 18 21:41:42 2016 -0500
|
||||
* Date: Fri Dec 23 23:08:01 2016 +0100
|
||||
*
|
||||
***
|
||||
*
|
||||
|
@ -1414,6 +1414,11 @@ var Point = Base.extend({
|
|||
return isNaN(this.x) || isNaN(this.y);
|
||||
},
|
||||
|
||||
isInQuadrant: function(q) {
|
||||
return this.x * (q > 1 && q < 4 ? -1 : 1) >= 0
|
||||
&& this.y * (q > 2 ? -1 : 1) >= 0;
|
||||
},
|
||||
|
||||
dot: function() {
|
||||
var point = Point.read(arguments);
|
||||
return this.x * point.x + this.y * point.y;
|
||||
|
@ -4799,20 +4804,22 @@ new function() {
|
|||
var radius = that._radius;
|
||||
if (!radius.isZero()) {
|
||||
var halfSize = that._size.divide(2);
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var dir = new Point(i & 1 ? 1 : -1, i > 1 ? 1 : -1),
|
||||
for (var q = 1; q <= 4; q++) {
|
||||
var dir = new Point(q > 1 && q < 4 ? -1 : 1, q > 2 ? -1 : 1),
|
||||
corner = dir.multiply(halfSize),
|
||||
center = corner.subtract(dir.multiply(radius)),
|
||||
rect = new Rectangle(corner, center);
|
||||
if ((expand ? rect.expand(expand) : rect).contains(point))
|
||||
return center;
|
||||
rect = new Rectangle(
|
||||
expand ? corner.add(dir.multiply(expand)) : corner,
|
||||
center);
|
||||
if (rect.contains(point))
|
||||
return { point: center, quadrant: q };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isOnEllipseStroke(point, radius, padding, quadrant) {
|
||||
var vector = point.divide(radius);
|
||||
return (!quadrant || vector.quadrant === quadrant) &&
|
||||
return (!quadrant || vector.isInQuadrant(quadrant)) &&
|
||||
vector.subtract(vector.normalize()).multiply(radius)
|
||||
.divide(padding).length <= 1;
|
||||
}
|
||||
|
@ -4822,7 +4829,7 @@ new function() {
|
|||
if (this._type === 'rectangle') {
|
||||
var center = getCornerCenter(this, point);
|
||||
return center
|
||||
? point.subtract(center).divide(this._radius)
|
||||
? point.subtract(center.point).divide(this._radius)
|
||||
.getLength() <= 1
|
||||
: _contains.base.call(this, point);
|
||||
} else {
|
||||
|
@ -4847,8 +4854,8 @@ new function() {
|
|||
var padding = strokePadding.multiply(2),
|
||||
center = getCornerCenter(this, point, padding);
|
||||
if (center) {
|
||||
hit = isOnEllipseStroke(point.subtract(center), radius,
|
||||
strokePadding, center.getQuadrant());
|
||||
hit = isOnEllipseStroke(point.subtract(center.point),
|
||||
radius, strokePadding, center.quadrant);
|
||||
} else {
|
||||
var rect = new Rectangle(this._size).setCenter(0, 0),
|
||||
outer = rect.expand(padding),
|
||||
|
|
45
dist/docs/classes/Point.html
vendored
45
dist/docs/classes/Point.html
vendored
|
@ -1592,6 +1592,51 @@ point2.x = 1; // doesn't change point1.x</code></pre>
|
|||
</div>
|
||||
|
||||
|
||||
<div id="isinquadrant-quadrant" class="member">
|
||||
<div class="member-link">
|
||||
<a name="isinquadrant-quadrant" href="#isinquadrant-quadrant"><tt><b>isInQuadrant</b>(quadrant)</tt></a>
|
||||
</div>
|
||||
<div class="member-description hidden">
|
||||
<div class="member-text">
|
||||
<p>Checks if the vector is within the specified quadrant. Note that if the vector lies on the boundary between two quadrants, <code>true</code> will be returned for both quadrants.</p>
|
||||
|
||||
|
||||
<ul class="member-list">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<li>
|
||||
<tt>quadrant:</tt>
|
||||
<tt>Number</tt>
|
||||
— the quadrant to check against
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="member-list">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<li>
|
||||
<tt><tt>Boolean</tt></tt> — <tt>true</tt> if either x or y are not a number, <tt>false</tt> otherwise
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="member-list">
|
||||
<h4>See also:</h4>
|
||||
|
||||
<li><tt><tt>#getQuadrant</tt>()</tt></li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h3>Vector Math Functions</h3>
|
||||
|
||||
<div id="dot-point" class="member">
|
||||
|
|
27
dist/paper-core.js
vendored
27
dist/paper-core.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Sun Dec 18 21:41:42 2016 -0500
|
||||
* Date: Fri Dec 23 23:08:01 2016 +0100
|
||||
*
|
||||
***
|
||||
*
|
||||
|
@ -1414,6 +1414,11 @@ var Point = Base.extend({
|
|||
return isNaN(this.x) || isNaN(this.y);
|
||||
},
|
||||
|
||||
isInQuadrant: function(q) {
|
||||
return this.x * (q > 1 && q < 4 ? -1 : 1) >= 0
|
||||
&& this.y * (q > 2 ? -1 : 1) >= 0;
|
||||
},
|
||||
|
||||
dot: function() {
|
||||
var point = Point.read(arguments);
|
||||
return this.x * point.x + this.y * point.y;
|
||||
|
@ -4799,20 +4804,22 @@ new function() {
|
|||
var radius = that._radius;
|
||||
if (!radius.isZero()) {
|
||||
var halfSize = that._size.divide(2);
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var dir = new Point(i & 1 ? 1 : -1, i > 1 ? 1 : -1),
|
||||
for (var q = 1; q <= 4; q++) {
|
||||
var dir = new Point(q > 1 && q < 4 ? -1 : 1, q > 2 ? -1 : 1),
|
||||
corner = dir.multiply(halfSize),
|
||||
center = corner.subtract(dir.multiply(radius)),
|
||||
rect = new Rectangle(corner, center);
|
||||
if ((expand ? rect.expand(expand) : rect).contains(point))
|
||||
return center;
|
||||
rect = new Rectangle(
|
||||
expand ? corner.add(dir.multiply(expand)) : corner,
|
||||
center);
|
||||
if (rect.contains(point))
|
||||
return { point: center, quadrant: q };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isOnEllipseStroke(point, radius, padding, quadrant) {
|
||||
var vector = point.divide(radius);
|
||||
return (!quadrant || vector.quadrant === quadrant) &&
|
||||
return (!quadrant || vector.isInQuadrant(quadrant)) &&
|
||||
vector.subtract(vector.normalize()).multiply(radius)
|
||||
.divide(padding).length <= 1;
|
||||
}
|
||||
|
@ -4822,7 +4829,7 @@ new function() {
|
|||
if (this._type === 'rectangle') {
|
||||
var center = getCornerCenter(this, point);
|
||||
return center
|
||||
? point.subtract(center).divide(this._radius)
|
||||
? point.subtract(center.point).divide(this._radius)
|
||||
.getLength() <= 1
|
||||
: _contains.base.call(this, point);
|
||||
} else {
|
||||
|
@ -4847,8 +4854,8 @@ new function() {
|
|||
var padding = strokePadding.multiply(2),
|
||||
center = getCornerCenter(this, point, padding);
|
||||
if (center) {
|
||||
hit = isOnEllipseStroke(point.subtract(center), radius,
|
||||
strokePadding, center.getQuadrant());
|
||||
hit = isOnEllipseStroke(point.subtract(center.point),
|
||||
radius, strokePadding, center.quadrant);
|
||||
} else {
|
||||
var rect = new Rectangle(this._size).setCenter(0, 0),
|
||||
outer = rect.expand(padding),
|
||||
|
|
16
dist/paper-core.min.js
vendored
16
dist/paper-core.min.js
vendored
File diff suppressed because one or more lines are too long
27
dist/paper-full.js
vendored
27
dist/paper-full.js
vendored
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Date: Sun Dec 18 21:41:42 2016 -0500
|
||||
* Date: Fri Dec 23 23:08:01 2016 +0100
|
||||
*
|
||||
***
|
||||
*
|
||||
|
@ -1414,6 +1414,11 @@ var Point = Base.extend({
|
|||
return isNaN(this.x) || isNaN(this.y);
|
||||
},
|
||||
|
||||
isInQuadrant: function(q) {
|
||||
return this.x * (q > 1 && q < 4 ? -1 : 1) >= 0
|
||||
&& this.y * (q > 2 ? -1 : 1) >= 0;
|
||||
},
|
||||
|
||||
dot: function() {
|
||||
var point = Point.read(arguments);
|
||||
return this.x * point.x + this.y * point.y;
|
||||
|
@ -4799,20 +4804,22 @@ new function() {
|
|||
var radius = that._radius;
|
||||
if (!radius.isZero()) {
|
||||
var halfSize = that._size.divide(2);
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var dir = new Point(i & 1 ? 1 : -1, i > 1 ? 1 : -1),
|
||||
for (var q = 1; q <= 4; q++) {
|
||||
var dir = new Point(q > 1 && q < 4 ? -1 : 1, q > 2 ? -1 : 1),
|
||||
corner = dir.multiply(halfSize),
|
||||
center = corner.subtract(dir.multiply(radius)),
|
||||
rect = new Rectangle(corner, center);
|
||||
if ((expand ? rect.expand(expand) : rect).contains(point))
|
||||
return center;
|
||||
rect = new Rectangle(
|
||||
expand ? corner.add(dir.multiply(expand)) : corner,
|
||||
center);
|
||||
if (rect.contains(point))
|
||||
return { point: center, quadrant: q };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isOnEllipseStroke(point, radius, padding, quadrant) {
|
||||
var vector = point.divide(radius);
|
||||
return (!quadrant || vector.quadrant === quadrant) &&
|
||||
return (!quadrant || vector.isInQuadrant(quadrant)) &&
|
||||
vector.subtract(vector.normalize()).multiply(radius)
|
||||
.divide(padding).length <= 1;
|
||||
}
|
||||
|
@ -4822,7 +4829,7 @@ new function() {
|
|||
if (this._type === 'rectangle') {
|
||||
var center = getCornerCenter(this, point);
|
||||
return center
|
||||
? point.subtract(center).divide(this._radius)
|
||||
? point.subtract(center.point).divide(this._radius)
|
||||
.getLength() <= 1
|
||||
: _contains.base.call(this, point);
|
||||
} else {
|
||||
|
@ -4847,8 +4854,8 @@ new function() {
|
|||
var padding = strokePadding.multiply(2),
|
||||
center = getCornerCenter(this, point, padding);
|
||||
if (center) {
|
||||
hit = isOnEllipseStroke(point.subtract(center), radius,
|
||||
strokePadding, center.getQuadrant());
|
||||
hit = isOnEllipseStroke(point.subtract(center.point),
|
||||
radius, strokePadding, center.quadrant);
|
||||
} else {
|
||||
var rect = new Rectangle(this._size).setCenter(0, 0),
|
||||
outer = rect.expand(padding),
|
||||
|
|
16
dist/paper-full.min.js
vendored
16
dist/paper-full.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue