mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Clean up code a bit and add comment about possible further optimsiations.
This commit is contained in:
parent
a3065a59d1
commit
680ae49ec8
1 changed files with 10 additions and 9 deletions
|
@ -801,8 +801,8 @@ var Path = this.Path = PathItem.extend({
|
||||||
centerY = -d / 2,
|
centerY = -d / 2,
|
||||||
radius = Math.sqrt(centerX * centerX + centerY * centerY - e),
|
radius = Math.sqrt(centerX * centerX + centerY * centerY - e),
|
||||||
|
|
||||||
// Note: reversing the Y equations negates the angle to adjust
|
// Note: reversing the Y equations negates the angle to adjust
|
||||||
// for the upside down coordinate system.
|
// for the upside down coordinate system.
|
||||||
angle = Math.atan2(centerY - y1, x1 - centerX),
|
angle = Math.atan2(centerY - y1, x1 - centerX),
|
||||||
middle = Math.atan2(centerY - y2, x2 - centerX),
|
middle = Math.atan2(centerY - y2, x2 - centerX),
|
||||||
extent = Math.atan2(centerY - y3, x3 - centerX),
|
extent = Math.atan2(centerY - y3, x3 - centerX),
|
||||||
|
@ -836,19 +836,20 @@ var Path = this.Path = PathItem.extend({
|
||||||
z = 4 / 3 * Math.sin(halfInc) / (1 + Math.cos(halfInc));
|
z = 4 / 3 * Math.sin(halfInc) / (1 + Math.cos(halfInc));
|
||||||
|
|
||||||
var segments = [];
|
var segments = [];
|
||||||
|
// TODO: Use Point#setAngle() and Point vector algebra instead.
|
||||||
for (var i = 0; i <= arcSegs; i++) {
|
for (var i = 0; i <= arcSegs; i++) {
|
||||||
var relx = Math.cos(angle),
|
var relx = Math.cos(angle),
|
||||||
rely = Math.sin(angle),
|
rely = Math.sin(angle),
|
||||||
pt = new Point(
|
pt = new Point(
|
||||||
centerX + relx * radius,
|
centerX + relx * radius,
|
||||||
centerY + rely * radius
|
centerY + rely * radius
|
||||||
);
|
),
|
||||||
var out = i == arcSegs
|
out = i == arcSegs
|
||||||
? null
|
? null
|
||||||
: new Point(
|
: new Point(
|
||||||
centerX + (relx - z * rely) * radius - pt.x,
|
centerX + (relx - z * rely) * radius - pt.x,
|
||||||
centerY + (rely + z * relx) * radius - pt.y
|
centerY + (rely + z * relx) * radius - pt.y
|
||||||
);
|
);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// Modify startSegment
|
// Modify startSegment
|
||||||
current.setHandleOut(out);
|
current.setHandleOut(out);
|
||||||
|
|
Loading…
Reference in a new issue