mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Merge remote branch 'origin/master'
This commit is contained in:
commit
dd2b546914
3 changed files with 17 additions and 19 deletions
|
@ -172,7 +172,7 @@ var Point = this.Point = Base.extend({
|
|||
}
|
||||
} else {
|
||||
var scale = length / this.getLength();
|
||||
if (scale == 0.0) {
|
||||
if (scale == 0) {
|
||||
// Calculate angle now, so it will be preserved even when
|
||||
// x and y are 0
|
||||
this.getAngle();
|
||||
|
|
|
@ -58,7 +58,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend({
|
|||
param.compound = true;
|
||||
for (var i = 0, l = this.children.length; i < l; i++)
|
||||
Item.draw(this.children[i], ctx, param);
|
||||
firstChild.setContextStyles(ctx);
|
||||
firstChild._setStyles(ctx);
|
||||
var fillColor = firstChild.getFillColor(),
|
||||
strokeColor = firstChild.getStrokeColor();
|
||||
if (fillColor) {
|
||||
|
|
|
@ -385,7 +385,7 @@ var Path = this.Path = PathItem.extend({
|
|||
var fillColor = this.getFillColor(),
|
||||
strokeColor = this.getStrokeColor();
|
||||
if (!param.compound && (fillColor || strokeColor)) {
|
||||
this.setContextStyles(ctx);
|
||||
this._setStyles(ctx);
|
||||
ctx.save();
|
||||
// If the path only defines a strokeColor or a fillColor,
|
||||
// draw it directly with the globalAlpha set, otherwise
|
||||
|
@ -463,7 +463,7 @@ var Path = this.Path = PathItem.extend({
|
|||
// Decomposition and forward substitution.
|
||||
for (var i = 1; i < n; i++) {
|
||||
tmp[i] = 1 / b;
|
||||
b = (i < n - 1 ? 4.0 : 2.0) - tmp[i];
|
||||
b = (i < n - 1 ? 4 : 2) - tmp[i];
|
||||
x[i] = (rhs[i] - x[i - 1]) / b;
|
||||
}
|
||||
// Back-substitution.
|
||||
|
@ -582,7 +582,7 @@ var Path = this.Path = PathItem.extend({
|
|||
}
|
||||
},
|
||||
|
||||
setContextStyles: function(ctx) {
|
||||
_setStyles: function(ctx) {
|
||||
for (var i in styles) {
|
||||
var style = this[i]();
|
||||
if (style)
|
||||
|
@ -646,9 +646,9 @@ var Path = this.Path = PathItem.extend({
|
|||
// and the cubic is A B C D,
|
||||
// B = E + 1/3 (A - E)
|
||||
// C = E + 1/3 (D - E)
|
||||
var current = getCurrentSegment(this);
|
||||
var current = getCurrentSegment(this)._point;
|
||||
this.cubicCurveTo(
|
||||
handle.add(current._point.subtract(handle).multiply(1/3)),
|
||||
handle.add(current.subtract(handle).multiply(1/3)),
|
||||
handle.add(to.subtract(handle).multiply(1/3)),
|
||||
to
|
||||
);
|
||||
|
@ -657,15 +657,13 @@ var Path = this.Path = PathItem.extend({
|
|||
curveTo: function(through, to, parameter) {
|
||||
through = Point.read(arguments, 0, 1);
|
||||
to = Point.read(arguments, 1, 1);
|
||||
var t = parameter;
|
||||
if (t == null)
|
||||
t = 0.5;
|
||||
var current = getCurrentSegment(this)._point;
|
||||
// handle = (through - (1 - t)^2 * current - t^2 * to) /
|
||||
// (2 * (1 - t) * t)
|
||||
var t1 = 1 - t,
|
||||
handle = through.subtract(current.multiply(t1 * t1)).subtract(
|
||||
to.multiply(t * t)).divide(2 * t * t1);
|
||||
var t = Base.pick(parameter, 0.5),
|
||||
t1 = 1 - t,
|
||||
current = getCurrentSegment(this)._point,
|
||||
// handle = (through - (1 - t)^2 * current - t^2 * to) /
|
||||
// (2 * (1 - t) * t)
|
||||
handle = through.subtract(current.multiply(t1 * t1))
|
||||
.subtract(to.multiply(t * t)).divide(2 * t * t1);
|
||||
if (handle.isNaN())
|
||||
throw new Error(
|
||||
"Cannot put a curve through points with parameter=" + t);
|
||||
|
@ -673,9 +671,9 @@ var Path = this.Path = PathItem.extend({
|
|||
},
|
||||
|
||||
arcTo: function(to, clockwise) {
|
||||
var through, to;
|
||||
// Get the start point:
|
||||
var current = getCurrentSegment(this);
|
||||
var current = getCurrentSegment(this),
|
||||
through;
|
||||
if (arguments[1] && typeof arguments[1] != 'boolean') {
|
||||
through = Point.read(arguments, 0, 1);
|
||||
to = Point.read(arguments, 1, 1);
|
||||
|
@ -720,7 +718,7 @@ var Path = this.Path = PathItem.extend({
|
|||
diff -= Math.PI * 2;
|
||||
|
||||
extent -= angle;
|
||||
if (extent <= 0.0)
|
||||
if (extent <= 0)
|
||||
extent += Math.PI * 2;
|
||||
|
||||
if (diff < 0) extent = Math.PI * 2 - extent;
|
||||
|
|
Loading…
Reference in a new issue