-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CircleArc } from "../CircleArc"; | ||
import { TWO_PI } from "../utils/angles"; | ||
|
||
export function makeSafeRenderingArc(arc: CircleArc): CircleArc { | ||
if (arc.startAngle != arc.endAngle) { | ||
return arc; | ||
} | ||
|
||
if (arc.isClockwise) { | ||
return new CircleArc(arc.circle, arc.startAngle, arc.endAngle + TWO_PI, arc.startPoint, arc.endPoint, true); | ||
} else { | ||
return new CircleArc(arc.circle, arc.startAngle + TWO_PI, arc.endAngle, arc.startPoint, arc.endPoint, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import assert from 'assert'; | ||
import { BezierHelper } from '../src'; | ||
import { RegionEngine } from '../src/RegionEngine'; | ||
|
||
describe("Bezier helper", () => { | ||
it("Tangent circles should render correctly", () => { | ||
const engine = new RegionEngine(); | ||
engine.add(-1, 0, 1); | ||
engine.add(+1, 0, 1); | ||
const regions = engine.computeRegions(); | ||
regions.forEach(r => { | ||
const poly = BezierHelper.renderPolygonArc( | ||
r, | ||
v => v.vcoords, | ||
anchors => anchors | ||
); | ||
assert.equal(poly.length > 2, true, `Received only ${poly.length} vertices!`); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters