Ellipse refactor

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2024-09-24 19:12:27 +02:00
parent 017047d15e
commit 3efa8735ef
No known key found for this signature in database
10 changed files with 301 additions and 217 deletions

View file

@ -1,5 +1,5 @@
import type { Radians } from "../math";
import { point } from "../math";
import { point, radians } from "../math";
import {
COLOR_PALETTE,
DEFAULT_CHART_COLOR_INDEX,
@ -205,7 +205,7 @@ const chartXLabels = (
x: x + index * (BAR_WIDTH + BAR_GAP) + BAR_GAP * 2,
y: y + BAR_GAP / 2,
width: BAR_WIDTH,
angle: 5.87 as Radians,
angle: radians(5.87),
fontSize: 16,
textAlign: "center",
verticalAlign: "top",

View file

@ -55,8 +55,8 @@ import {
getNormalizedGridStep,
getNormalizedZoom,
} from "../scene";
import type { LocalPoint, Radians } from "../../math";
import { pointExtent, isFiniteNumber, point } from "../../math";
import type { LocalPoint } from "../../math";
import { pointExtent, isFiniteNumber, point, radians } from "../../math";
type RestoredAppState = Omit<
AppState,
@ -153,7 +153,7 @@ const restoreElementWithProperties = <
roughness: element.roughness ?? DEFAULT_ELEMENT_PROPS.roughness,
opacity:
element.opacity == null ? DEFAULT_ELEMENT_PROPS.opacity : element.opacity,
angle: element.angle || (0 as Radians),
angle: element.angle || radians(0),
x: extra.x ?? element.x ?? 0,
y: extra.y ?? element.y ?? 0,
strokeColor: element.strokeColor || DEFAULT_ELEMENT_PROPS.strokeColor,

View file

@ -73,6 +73,7 @@ import {
pointFromPair,
pointDistanceSq,
clamp,
radians,
} from "../../math";
import { segmentIntersectRectangleElement } from "../../utils/geometry/shape";
@ -845,7 +846,7 @@ export const avoidRectangularCorner = (
element.x + element.width / 2,
element.y + element.height / 2,
);
const nonRotatedPoint = pointRotateRads(p, center, -element.angle as Radians);
const nonRotatedPoint = pointRotateRads(p, center, radians(-element.angle));
if (nonRotatedPoint[0] < element.x && nonRotatedPoint[1] < element.y) {
// Top left