mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Add visual debug support for arc
This commit is contained in:
parent
85611b8754
commit
2ec3374333
3 changed files with 67 additions and 4 deletions
|
@ -12,7 +12,13 @@ import {
|
|||
TrashIcon,
|
||||
} from "../../packages/excalidraw/components/icons";
|
||||
import { STORAGE_KEYS } from "../app_constants";
|
||||
import { isSegment, type GlobalPoint, type Segment } from "../../packages/math";
|
||||
import type { Arc } from "../../packages/math";
|
||||
import {
|
||||
isArc,
|
||||
isSegment,
|
||||
type GlobalPoint,
|
||||
type Segment,
|
||||
} from "../../packages/math";
|
||||
|
||||
const renderLine = (
|
||||
context: CanvasRenderingContext2D,
|
||||
|
@ -29,6 +35,26 @@ const renderLine = (
|
|||
context.restore();
|
||||
};
|
||||
|
||||
const renderArc = (
|
||||
context: CanvasRenderingContext2D,
|
||||
zoom: number,
|
||||
a: Arc<GlobalPoint>,
|
||||
color: string,
|
||||
) => {
|
||||
context.save();
|
||||
context.strokeStyle = color;
|
||||
context.beginPath();
|
||||
context.arc(
|
||||
a.center[0] * zoom,
|
||||
a.center[1] * zoom,
|
||||
a.radius * zoom,
|
||||
a.startAngle,
|
||||
a.endAngle,
|
||||
);
|
||||
context.stroke();
|
||||
context.restore();
|
||||
};
|
||||
|
||||
const renderOrigin = (context: CanvasRenderingContext2D, zoom: number) => {
|
||||
context.strokeStyle = "#888";
|
||||
context.save();
|
||||
|
@ -56,6 +82,14 @@ const render = (
|
|||
el.color,
|
||||
);
|
||||
break;
|
||||
case isArc(el.data):
|
||||
renderArc(
|
||||
context,
|
||||
appState.zoom.value,
|
||||
el.data as Arc<GlobalPoint>,
|
||||
el.color,
|
||||
);
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue