blob: 0a11c1ef2697255a34abce63cd62a67c6da558f8 (
plain)
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
|
import { nodeOrNew, register, wrapWithAttrCheck } from '../utils/adopter.js'
import { registerMethods } from '../utils/methods.js'
import Container from './Container.js'
export default class G extends Container {
constructor (node) {
super(nodeOrNew('g', node), node)
}
x (x) {
if (x == null) return this.transform()['x']
return this.move(x, 0)
}
y (y) {
if (y == null) return this.transform()['y']
return this.move(0, y)
}
move (x, y) {
return this.translate(x, y)
}
dx (dx) {
return this.transform({ dx }, true)
}
dy (dy) {
return this.transform({ dy }, true)
}
dmove (dx, dy) {
return this.transform({ dx, dy }, true)
}
width () {
return this.bbox().width
}
height () {
return this.bbox().height
}
}
registerMethods({
Element: {
// Create a group element
group: wrapWithAttrCheck(function () {
return this.put(new G())
})
}
})
register(G)
|