1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import { cx, cy, height, width, x, y } from '../modules/core/circled.js'
import {
extend,
nodeOrNew,
register,
wrapWithAttrCheck
} from '../utils/adopter.js'
import { registerMethods } from '../utils/methods.js'
import SVGNumber from '../types/SVGNumber.js'
import Shape from './Shape.js'
export default class Circle extends Shape {
constructor ( node ) {
super( nodeOrNew( 'circle', node ), node )
}
radius ( r ) {
return this.attr( 'r', r )
}
// Radius x value
rx ( rx ) {
return this.attr( 'r', rx )
}
// Alias radius x value
ry ( ry ) {
return this.rx( ry )
}
size ( size ) {
return this.radius( new SVGNumber( size ).divide( 2 ) )
}
}
extend( Circle, { x, y, cx, cy, width, height } )
registerMethods( {
Element: {
// Create circle element
circle: wrapWithAttrCheck( function ( size ) {
return this.put( new Circle() )
.size( size )
.move( 0, 0 )
} )
}
} )
register( Circle )
|