Merge remote branch 'origin/master'

This commit is contained in:
Jonathan Puckey 2011-04-28 14:22:44 +02:00
commit dd2b546914
3 changed files with 17 additions and 19 deletions

View file

@ -172,7 +172,7 @@ var Point = this.Point = Base.extend({
} }
} else { } else {
var scale = length / this.getLength(); var scale = length / this.getLength();
if (scale == 0.0) { if (scale == 0) {
// Calculate angle now, so it will be preserved even when // Calculate angle now, so it will be preserved even when
// x and y are 0 // x and y are 0
this.getAngle(); this.getAngle();

View file

@ -58,7 +58,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend({
param.compound = true; param.compound = true;
for (var i = 0, l = this.children.length; i < l; i++) for (var i = 0, l = this.children.length; i < l; i++)
Item.draw(this.children[i], ctx, param); Item.draw(this.children[i], ctx, param);
firstChild.setContextStyles(ctx); firstChild._setStyles(ctx);
var fillColor = firstChild.getFillColor(), var fillColor = firstChild.getFillColor(),
strokeColor = firstChild.getStrokeColor(); strokeColor = firstChild.getStrokeColor();
if (fillColor) { if (fillColor) {

View file

@ -385,7 +385,7 @@ var Path = this.Path = PathItem.extend({
var fillColor = this.getFillColor(), var fillColor = this.getFillColor(),
strokeColor = this.getStrokeColor(); strokeColor = this.getStrokeColor();
if (!param.compound && (fillColor || strokeColor)) { if (!param.compound && (fillColor || strokeColor)) {
this.setContextStyles(ctx); this._setStyles(ctx);
ctx.save(); ctx.save();
// If the path only defines a strokeColor or a fillColor, // If the path only defines a strokeColor or a fillColor,
// draw it directly with the globalAlpha set, otherwise // draw it directly with the globalAlpha set, otherwise
@ -463,7 +463,7 @@ var Path = this.Path = PathItem.extend({
// Decomposition and forward substitution. // Decomposition and forward substitution.
for (var i = 1; i < n; i++) { for (var i = 1; i < n; i++) {
tmp[i] = 1 / b; 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; x[i] = (rhs[i] - x[i - 1]) / b;
} }
// Back-substitution. // Back-substitution.
@ -582,7 +582,7 @@ var Path = this.Path = PathItem.extend({
} }
}, },
setContextStyles: function(ctx) { _setStyles: function(ctx) {
for (var i in styles) { for (var i in styles) {
var style = this[i](); var style = this[i]();
if (style) if (style)
@ -646,9 +646,9 @@ var Path = this.Path = PathItem.extend({
// and the cubic is A B C D, // and the cubic is A B C D,
// B = E + 1/3 (A - E) // B = E + 1/3 (A - E)
// C = E + 1/3 (D - E) // C = E + 1/3 (D - E)
var current = getCurrentSegment(this); var current = getCurrentSegment(this)._point;
this.cubicCurveTo( 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)), handle.add(to.subtract(handle).multiply(1/3)),
to to
); );
@ -657,15 +657,13 @@ var Path = this.Path = PathItem.extend({
curveTo: function(through, to, parameter) { curveTo: function(through, to, parameter) {
through = Point.read(arguments, 0, 1); through = Point.read(arguments, 0, 1);
to = Point.read(arguments, 1, 1); to = Point.read(arguments, 1, 1);
var t = parameter; var t = Base.pick(parameter, 0.5),
if (t == null) t1 = 1 - t,
t = 0.5; current = getCurrentSegment(this)._point,
var current = getCurrentSegment(this)._point; // handle = (through - (1 - t)^2 * current - t^2 * to) /
// handle = (through - (1 - t)^2 * current - t^2 * to) / // (2 * (1 - t) * t)
// (2 * (1 - t) * t) handle = through.subtract(current.multiply(t1 * t1))
var t1 = 1 - t, .subtract(to.multiply(t * t)).divide(2 * t * t1);
handle = through.subtract(current.multiply(t1 * t1)).subtract(
to.multiply(t * t)).divide(2 * t * t1);
if (handle.isNaN()) if (handle.isNaN())
throw new Error( throw new Error(
"Cannot put a curve through points with parameter=" + t); "Cannot put a curve through points with parameter=" + t);
@ -673,9 +671,9 @@ var Path = this.Path = PathItem.extend({
}, },
arcTo: function(to, clockwise) { arcTo: function(to, clockwise) {
var through, to;
// Get the start point: // Get the start point:
var current = getCurrentSegment(this); var current = getCurrentSegment(this),
through;
if (arguments[1] && typeof arguments[1] != 'boolean') { if (arguments[1] && typeof arguments[1] != 'boolean') {
through = Point.read(arguments, 0, 1); through = Point.read(arguments, 0, 1);
to = Point.read(arguments, 1, 1); to = Point.read(arguments, 1, 1);
@ -720,7 +718,7 @@ var Path = this.Path = PathItem.extend({
diff -= Math.PI * 2; diff -= Math.PI * 2;
extent -= angle; extent -= angle;
if (extent <= 0.0) if (extent <= 0)
extent += Math.PI * 2; extent += Math.PI * 2;
if (diff < 0) extent = Math.PI * 2 - extent; if (diff < 0) extent = Math.PI * 2 - extent;