-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
πππ»ββοΈ β [SSM-79 SSM-80]: Annotation tool now has shapes
- Loading branch information
1 parent
2213242
commit e3f2531
Showing
5 changed files
with
146 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Point, Shape } from '../Annotation'; | ||
|
||
export const createShapePath = (shape: Shape): string => { | ||
const { type, startPoint, endPoint } = shape; | ||
|
||
switch (type) { | ||
case 'rectangle': { | ||
const width = endPoint.x - startPoint.x; | ||
const height = endPoint.y - startPoint.y; | ||
return `M ${startPoint.x},${startPoint.y} h ${width} v ${height} h ${-width} Z`; | ||
} | ||
case 'circle': { | ||
const rx = Math.abs(endPoint.x - startPoint.x) / 2; | ||
const ry = Math.abs(endPoint.y - startPoint.y) / 2; | ||
const cx = startPoint.x + (endPoint.x - startPoint.x) / 2; | ||
const cy = startPoint.y + (endPoint.y - startPoint.y) / 2; | ||
return `M ${cx - rx},${cy} a ${rx},${ry} 0 1,0 ${rx * 2},0 a ${rx},${ry} 0 1,0 ${-rx * 2},0`; | ||
} | ||
default: | ||
return ''; | ||
} | ||
}; |