mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
ellipse and arc refactors
This commit is contained in:
parent
3efa8735ef
commit
392dd5b0b8
9 changed files with 125 additions and 94 deletions
|
@ -42,8 +42,6 @@ const calculateTranslation = (
|
|||
maxY: selectionBounds[3],
|
||||
midX: (selectionBounds[0] + selectionBounds[2]) / 2,
|
||||
midY: (selectionBounds[1] + selectionBounds[3]) / 2,
|
||||
width: selectionBounds[2] - selectionBounds[0],
|
||||
height: selectionBounds[3] - selectionBounds[1],
|
||||
};
|
||||
const groupBounds = getCommonBounds(group);
|
||||
const groupBoundingBox = {
|
||||
|
@ -53,8 +51,6 @@ const calculateTranslation = (
|
|||
maxY: groupBounds[3],
|
||||
midX: (groupBounds[0] + groupBounds[2]) / 2,
|
||||
midY: (groupBounds[1] + groupBounds[3]) / 2,
|
||||
width: groupBounds[2] - groupBounds[0],
|
||||
height: groupBounds[3] - groupBounds[1],
|
||||
};
|
||||
|
||||
const [min, max]: ["minX" | "minY", "maxX" | "maxY"] =
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
isTextElement,
|
||||
} from "./typeChecks";
|
||||
import { getBoundTextShape } from "../shapes";
|
||||
import type { GlobalPoint, LocalPoint, Polygon } from "../../math";
|
||||
import type { GlobalPoint, Polygon } from "../../math";
|
||||
import { pathIsALoop, isPointWithinBounds, point } from "../../math";
|
||||
import { LINE_CONFIRM_THRESHOLD } from "../constants";
|
||||
|
||||
|
@ -48,10 +48,10 @@ export const shouldTestInside = (element: ExcalidrawElement) => {
|
|||
return isDraggableFromInside || isImageElement(element);
|
||||
};
|
||||
|
||||
export type HitTestArgs<Point extends GlobalPoint | LocalPoint> = {
|
||||
sceneCoords: Point;
|
||||
export type HitTestArgs = {
|
||||
sceneCoords: GlobalPoint;
|
||||
element: ExcalidrawElement;
|
||||
shape: GeometricShape<Point>;
|
||||
shape: GeometricShape<GlobalPoint>;
|
||||
threshold?: number;
|
||||
frameNameBound?: FrameNameBounds | null;
|
||||
};
|
||||
|
@ -62,7 +62,7 @@ export const hitElementItself = ({
|
|||
shape,
|
||||
threshold = 10,
|
||||
frameNameBound = null,
|
||||
}: HitTestArgs<GlobalPoint>) => {
|
||||
}: HitTestArgs) => {
|
||||
let hit = shouldTestInside(element)
|
||||
? // Since `inShape` tests STRICTLY againt the insides of a shape
|
||||
// we would need `onShape` as well to include the "borders"
|
||||
|
@ -97,7 +97,7 @@ export const hitElementBoundingBox = (
|
|||
};
|
||||
|
||||
export const hitElementBoundingBoxOnly = (
|
||||
hitArgs: HitTestArgs<GlobalPoint>,
|
||||
hitArgs: HitTestArgs,
|
||||
elementsMap: ElementsMap,
|
||||
) => {
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue