mirror of
https://github.com/excalidraw/excalidraw.git
synced 2024-11-10 11:35:52 +01:00
fix: hit test for closed sharp curves (#7881)
This commit is contained in:
parent
0ae9b383d6
commit
4689a6b300
@ -4383,6 +4383,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
return shouldTestInside(element)
|
return shouldTestInside(element)
|
||||||
? getClosedCurveShape(
|
? getClosedCurveShape(
|
||||||
|
element,
|
||||||
roughShape,
|
roughShape,
|
||||||
[element.x, element.y],
|
[element.x, element.y],
|
||||||
element.angle,
|
element.angle,
|
||||||
|
@ -20,6 +20,7 @@ import {
|
|||||||
ExcalidrawFreeDrawElement,
|
ExcalidrawFreeDrawElement,
|
||||||
ExcalidrawIframeElement,
|
ExcalidrawIframeElement,
|
||||||
ExcalidrawImageElement,
|
ExcalidrawImageElement,
|
||||||
|
ExcalidrawLinearElement,
|
||||||
ExcalidrawRectangleElement,
|
ExcalidrawRectangleElement,
|
||||||
ExcalidrawSelectionElement,
|
ExcalidrawSelectionElement,
|
||||||
ExcalidrawTextElement,
|
ExcalidrawTextElement,
|
||||||
@ -233,12 +234,12 @@ export const getFreedrawShape = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getClosedCurveShape = (
|
export const getClosedCurveShape = (
|
||||||
|
element: ExcalidrawLinearElement,
|
||||||
roughShape: Drawable,
|
roughShape: Drawable,
|
||||||
startingPoint: Point = [0, 0],
|
startingPoint: Point = [0, 0],
|
||||||
angleInRadian: number,
|
angleInRadian: number,
|
||||||
center: Point,
|
center: Point,
|
||||||
): GeometricShape => {
|
): GeometricShape => {
|
||||||
const ops = getCurvePathOps(roughShape);
|
|
||||||
const transform = (p: Point) =>
|
const transform = (p: Point) =>
|
||||||
pointRotate(
|
pointRotate(
|
||||||
[p[0] + startingPoint[0], p[1] + startingPoint[1]],
|
[p[0] + startingPoint[0], p[1] + startingPoint[1]],
|
||||||
@ -246,6 +247,15 @@ export const getClosedCurveShape = (
|
|||||||
center,
|
center,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (element.roundness === null) {
|
||||||
|
return {
|
||||||
|
type: "polygon",
|
||||||
|
data: close(element.points.map((p) => transform(p as Point))),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const ops = getCurvePathOps(roughShape);
|
||||||
|
|
||||||
const points: Point[] = [];
|
const points: Point[] = [];
|
||||||
let odd = false;
|
let odd = false;
|
||||||
for (const operation of ops) {
|
for (const operation of ops) {
|
||||||
|
Loading…
Reference in New Issue
Block a user