|
|
@@ -1,4 +1,4 @@
|
|
1
|
|
-import { uniqueId } from 'utils/utils'
|
|
|
1
|
+import { uniqueId, getPerfectEllipseDashProps } from 'utils/utils'
|
|
2
|
2
|
import vec from 'utils/vec'
|
|
3
|
3
|
import { DashStyle, EllipseShape, ShapeType } from 'types'
|
|
4
|
4
|
import { getShapeUtils } from './index'
|
|
|
@@ -6,11 +6,7 @@ import { boundsContained, getRotatedEllipseBounds } from 'utils/bounds'
|
|
6
|
6
|
import { intersectEllipseBounds } from 'utils/intersections'
|
|
7
|
7
|
import { pointInEllipse } from 'utils/hitTests'
|
|
8
|
8
|
import { ease, getSvgPathFromStroke, rng, translateBounds } from 'utils/utils'
|
|
9
|
|
-import {
|
|
10
|
|
- defaultStyle,
|
|
11
|
|
- getShapeStyle,
|
|
12
|
|
- getStrokeDashArray,
|
|
13
|
|
-} from 'state/shape-styles'
|
|
|
9
|
+import { defaultStyle, getShapeStyle } from 'state/shape-styles'
|
|
14
|
10
|
import getStroke from 'perfect-freehand'
|
|
15
|
11
|
import { registerShapeUtils } from './register'
|
|
16
|
12
|
|
|
|
@@ -43,6 +39,7 @@ const ellipse = registerShapeUtils<EllipseShape>({
|
|
43
|
39
|
render(shape) {
|
|
44
|
40
|
const { id, radiusX, radiusY, style } = shape
|
|
45
|
41
|
const styles = getShapeStyle(style)
|
|
|
42
|
+ const strokeWidth = +styles.strokeWidth
|
|
46
|
43
|
|
|
47
|
44
|
if (style.dash === DashStyle.Solid) {
|
|
48
|
45
|
if (!pathCache.has(shape)) {
|
|
|
@@ -57,8 +54,8 @@ const ellipse = registerShapeUtils<EllipseShape>({
|
|
57
|
54
|
id={id}
|
|
58
|
55
|
cx={radiusX}
|
|
59
|
56
|
cy={radiusY}
|
|
60
|
|
- rx={Math.max(0, radiusX - +styles.strokeWidth / 2)}
|
|
61
|
|
- ry={Math.max(0, radiusY - +styles.strokeWidth / 2)}
|
|
|
57
|
+ rx={Math.max(0, radiusX - strokeWidth / 2)}
|
|
|
58
|
+ ry={Math.max(0, radiusY - strokeWidth / 2)}
|
|
62
|
59
|
stroke="none"
|
|
63
|
60
|
/>
|
|
64
|
61
|
<path d={path} fill={styles.stroke} />
|
|
|
@@ -66,20 +63,30 @@ const ellipse = registerShapeUtils<EllipseShape>({
|
|
66
|
63
|
)
|
|
67
|
64
|
}
|
|
68
|
65
|
|
|
|
66
|
+ const rx = Math.max(0, radiusX - strokeWidth / 2)
|
|
|
67
|
+ const ry = Math.max(0, radiusY - strokeWidth / 2)
|
|
|
68
|
+
|
|
|
69
|
+ const { strokeDasharray, strokeDashoffset } = getPerfectEllipseDashProps(
|
|
|
70
|
+ rx,
|
|
|
71
|
+ ry,
|
|
|
72
|
+ strokeWidth,
|
|
|
73
|
+ shape.style.dash === DashStyle.Dotted ? 'dotted' : 'dashed'
|
|
|
74
|
+ )
|
|
|
75
|
+
|
|
69
|
76
|
return (
|
|
70
|
|
- <ellipse
|
|
71
|
|
- id={id}
|
|
72
|
|
- cx={radiusX}
|
|
73
|
|
- cy={radiusY}
|
|
74
|
|
- rx={Math.max(0, radiusX - +styles.strokeWidth / 2)}
|
|
75
|
|
- ry={Math.max(0, radiusY - +styles.strokeWidth / 2)}
|
|
76
|
|
- fill={styles.fill}
|
|
77
|
|
- stroke={styles.stroke}
|
|
78
|
|
- strokeDasharray={getStrokeDashArray(
|
|
79
|
|
- style.dash,
|
|
80
|
|
- +styles.strokeWidth
|
|
81
|
|
- ).join(' ')}
|
|
82
|
|
- />
|
|
|
77
|
+ <g id={id}>
|
|
|
78
|
+ <ellipse
|
|
|
79
|
+ id={id}
|
|
|
80
|
+ cx={radiusX}
|
|
|
81
|
+ cy={radiusY}
|
|
|
82
|
+ rx={rx}
|
|
|
83
|
+ ry={ry}
|
|
|
84
|
+ fill={styles.fill}
|
|
|
85
|
+ stroke={styles.stroke}
|
|
|
86
|
+ strokeDasharray={strokeDasharray}
|
|
|
87
|
+ strokeDashoffset={strokeDashoffset}
|
|
|
88
|
+ />
|
|
|
89
|
+ </g>
|
|
83
|
90
|
)
|
|
84
|
91
|
},
|
|
85
|
92
|
|