mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Correct Numerical.KAPPA value.
This commit is contained in:
parent
9da392a99c
commit
bf9acd4499
4 changed files with 11 additions and 10 deletions
|
@ -43,11 +43,11 @@ var Shape = this.Shape = Item.extend(/** @lends Shape# */{
|
|||
ctx.arc(0, 0, width, 0, Math.PI * 2, true);
|
||||
break;
|
||||
case 'ellipse':
|
||||
var kappa = Numerical.KAPPA,
|
||||
cx = width * kappa,
|
||||
cy = height * kappa,
|
||||
mx = width / 2,
|
||||
my = height / 2;
|
||||
var mx = width / 2,
|
||||
my = height / 2,
|
||||
kappa = Numerical.KAPPA,
|
||||
cx = mx * kappa,
|
||||
cy = my * kappa;
|
||||
ctx.moveTo(0, my);
|
||||
ctx.bezierCurveTo(0, my - cy, mx - cx, 0, mx, 0);
|
||||
ctx.bezierCurveTo(mx + cx, 0, width, my - cy, width, my);
|
||||
|
|
|
@ -56,7 +56,7 @@ Path.inject({ statics: new function() {
|
|||
return path;
|
||||
}
|
||||
|
||||
var kappa = Numerical.KAPPA;
|
||||
var kappa = Numerical.KAPPA / 2;
|
||||
|
||||
var ellipseSegments = [
|
||||
new Segment([0, 0.5], [0, kappa ], [0, -kappa]),
|
||||
|
|
|
@ -120,7 +120,8 @@ new function() {
|
|||
var segment = segments[i],
|
||||
next = segment.getNext(),
|
||||
handle1 = segment._handleOut,
|
||||
handle2 = next._handleIn;
|
||||
handle2 = next._handleIn,
|
||||
kappa = Numerical.KAPPA;
|
||||
if (handle1.isOrthogonal(handle2)) {
|
||||
var from = segment._point,
|
||||
to = next._point,
|
||||
|
@ -129,9 +130,9 @@ new function() {
|
|||
corner = new Line(from, handle1).intersect(
|
||||
new Line(to, handle2));
|
||||
return corner && Numerical.isZero(handle1.getLength() /
|
||||
corner.subtract(from).getLength() - Numerical.KAPPA)
|
||||
corner.subtract(from).getLength() - kappa)
|
||||
&& Numerical.isZero(handle2.getLength() /
|
||||
corner.subtract(to).getLength() - Numerical.KAPPA);
|
||||
corner.subtract(to).getLength() - kappa);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ var Numerical = this.Numerical = new function() {
|
|||
// TODO: Find a good value
|
||||
EPSILON: 10e-12,
|
||||
// Kappa, see: http://www.whizkidtech.redprince.net/bezier/circle/kappa/
|
||||
KAPPA: 2 * (sqrt(2) - 1) / 3,
|
||||
KAPPA: 4 * (sqrt(2) - 1) / 3,
|
||||
|
||||
/**
|
||||
* Check if the value is 0, within a tolerance defined by
|
||||
|
|
Loading…
Reference in a new issue