mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Add ellipse changes no angle
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
parent
d9ea7190ec
commit
7b4e989d65
12 changed files with 97 additions and 357 deletions
|
@ -1,4 +1,3 @@
|
|||
import { radians } from "./angle";
|
||||
import {
|
||||
ellipse,
|
||||
ellipseSegmentInterceptPoints,
|
||||
|
@ -10,29 +9,29 @@ import { segment } from "./segment";
|
|||
import type { Ellipse, GlobalPoint } from "./types";
|
||||
|
||||
describe("point and ellipse", () => {
|
||||
const target: Ellipse<GlobalPoint> = ellipse(point(0, 0), radians(0), 2, 1);
|
||||
|
||||
it("point on ellipse", () => {
|
||||
[point(0, 1), point(0, -1), point(2, 0), point(-2, 0)].forEach((p) => {
|
||||
const target: Ellipse<GlobalPoint> = ellipse(point(1, 2), 2, 1);
|
||||
[point(1, 3), point(1, 1), point(3, 2), point(-1, 2)].forEach((p) => {
|
||||
expect(ellipseTouchesPoint(p, target)).toBe(true);
|
||||
});
|
||||
expect(ellipseTouchesPoint(point(-1.4, 0.7), target, 0.1)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(-1.4, 0.71), target, 0.01)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(-0.4, 2.7), target, 0.1)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(-0.4, 2.71), target, 0.01)).toBe(true);
|
||||
|
||||
expect(ellipseTouchesPoint(point(1.4, 0.7), target, 0.1)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(1.4, 0.71), target, 0.01)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(2.4, 2.7), target, 0.1)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(2.4, 2.71), target, 0.01)).toBe(true);
|
||||
|
||||
expect(ellipseTouchesPoint(point(1, -0.86), target, 0.1)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(1, -0.86), target, 0.01)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(2, 1.14), target, 0.1)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(2, 1.14), target, 0.01)).toBe(true);
|
||||
|
||||
expect(ellipseTouchesPoint(point(-1, -0.86), target, 0.1)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(-1, -0.86), target, 0.01)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(0, 1.14), target, 0.1)).toBe(true);
|
||||
expect(ellipseTouchesPoint(point(0, 1.14), target, 0.01)).toBe(true);
|
||||
|
||||
expect(ellipseTouchesPoint(point(-1, 0.8), target)).toBe(false);
|
||||
expect(ellipseTouchesPoint(point(1, -0.8), target)).toBe(false);
|
||||
expect(ellipseTouchesPoint(point(0, 2.8), target)).toBe(false);
|
||||
expect(ellipseTouchesPoint(point(2, 1.2), target)).toBe(false);
|
||||
});
|
||||
|
||||
it("point in ellipse", () => {
|
||||
const target: Ellipse<GlobalPoint> = ellipse(point(0, 0), 2, 1);
|
||||
[point(0, 1), point(0, -1), point(2, 0), point(-2, 0)].forEach((p) => {
|
||||
expect(ellipseIncludesPoint(p, target)).toBe(true);
|
||||
});
|
||||
|
@ -50,7 +49,7 @@ describe("point and ellipse", () => {
|
|||
|
||||
describe("line and ellipse", () => {
|
||||
it("detects outside segment", () => {
|
||||
const e = ellipse(point(0, 0), radians(0), 2, 2);
|
||||
const e = ellipse(point(0, 0), 2, 2);
|
||||
|
||||
expect(
|
||||
ellipseSegmentInterceptPoints(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue