|
|
@@ -1,12 +1,16 @@
|
|
1
|
1
|
import { uniqueId } from 'utils/utils'
|
|
2
|
2
|
import vec from 'utils/vec'
|
|
3
|
|
-import { EllipseShape, ShapeType } from 'types'
|
|
|
3
|
+import { DashStyle, EllipseShape, ShapeType } from 'types'
|
|
4
|
4
|
import { getShapeUtils } from './index'
|
|
5
|
5
|
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 { defaultStyle, getShapeStyle } from 'state/shape-styles'
|
|
|
9
|
+import {
|
|
|
10
|
+ defaultStyle,
|
|
|
11
|
+ getShapeStyle,
|
|
|
12
|
+ getStrokeDashArray,
|
|
|
13
|
+} from 'state/shape-styles'
|
|
10
|
14
|
import getStroke from 'perfect-freehand'
|
|
11
|
15
|
import { registerShapeUtils } from './register'
|
|
12
|
16
|
|
|
|
@@ -40,35 +44,43 @@ const ellipse = registerShapeUtils<EllipseShape>({
|
|
40
|
44
|
const { id, radiusX, radiusY, style } = shape
|
|
41
|
45
|
const styles = getShapeStyle(style)
|
|
42
|
46
|
|
|
43
|
|
- if (!pathCache.has(shape)) {
|
|
44
|
|
- renderPath(shape)
|
|
45
|
|
- }
|
|
|
47
|
+ if (style.dash === DashStyle.Solid) {
|
|
|
48
|
+ if (!pathCache.has(shape)) {
|
|
|
49
|
+ renderPath(shape)
|
|
|
50
|
+ }
|
|
46
|
51
|
|
|
47
|
|
- const path = pathCache.get(shape)
|
|
|
52
|
+ const path = pathCache.get(shape)
|
|
|
53
|
+
|
|
|
54
|
+ return (
|
|
|
55
|
+ <g id={id}>
|
|
|
56
|
+ <ellipse
|
|
|
57
|
+ id={id}
|
|
|
58
|
+ cx={radiusX}
|
|
|
59
|
+ cy={radiusY}
|
|
|
60
|
+ rx={Math.max(0, radiusX - +styles.strokeWidth / 2)}
|
|
|
61
|
+ ry={Math.max(0, radiusY - +styles.strokeWidth / 2)}
|
|
|
62
|
+ stroke="none"
|
|
|
63
|
+ />
|
|
|
64
|
+ <path d={path} fill={styles.stroke} />
|
|
|
65
|
+ </g>
|
|
|
66
|
+ )
|
|
|
67
|
+ }
|
|
48
|
68
|
|
|
49
|
69
|
return (
|
|
50
|
|
- <g id={id}>
|
|
51
|
|
- <ellipse
|
|
52
|
|
- id={id}
|
|
53
|
|
- cx={radiusX}
|
|
54
|
|
- cy={radiusY}
|
|
55
|
|
- rx={Math.max(0, radiusX - Number(styles.strokeWidth) / 2)}
|
|
56
|
|
- ry={Math.max(0, radiusY - Number(styles.strokeWidth) / 2)}
|
|
57
|
|
- stroke="none"
|
|
58
|
|
- />
|
|
59
|
|
- <path d={path} fill={styles.stroke} />
|
|
60
|
|
- </g>
|
|
|
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
|
+ />
|
|
61
|
83
|
)
|
|
62
|
|
-
|
|
63
|
|
- // return (
|
|
64
|
|
- // <ellipse
|
|
65
|
|
- // id={id}
|
|
66
|
|
- // cx={radiusX}
|
|
67
|
|
- // cy={radiusY}
|
|
68
|
|
- // rx={Math.max(0, radiusX - Number(styles.strokeWidth) / 2)}
|
|
69
|
|
- // ry={Math.max(0, radiusY - Number(styles.strokeWidth) / 2)}
|
|
70
|
|
- // />
|
|
71
|
|
- // )
|
|
72
|
84
|
},
|
|
73
|
85
|
|
|
74
|
86
|
getBounds(shape) {
|