blob: 9a3b1ad43ab72ea9b1874253e3e79c7419ab5ce4 (
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
55
56
57
58
59
60
61
62
63
64
|
// FIXME: import this to runner
import { proportionalSize } from '../../utils/utils.js'
import SVGNumber from '../../types/SVGNumber.js'
// Radius x value
export function rx (rx) {
return this.attr('rx', rx)
}
// Radius y value
export function ry (ry) {
return this.attr('ry', ry)
}
// Move over x-axis
export function x (x) {
return x == null
? this.cx() - this.rx()
: this.cx(x + this.rx())
}
// Move over y-axis
export function y (y) {
return y == null
? this.cy() - this.ry()
: this.cy(y + this.ry())
}
// Move by center over x-axis
export function cx (x) {
return x == null
? this.attr('cx')
: this.attr('cx', x)
}
// Move by center over y-axis
export function cy (y) {
return y == null
? this.attr('cy')
: this.attr('cy', y)
}
// Set width of element
export function width (width) {
return width == null
? this.rx() * 2
: this.rx(new SVGNumber(width).divide(2))
}
// Set height of element
export function height (height) {
return height == null
? this.ry() * 2
: this.ry(new SVGNumber(height).divide(2))
}
// Custom size function
export function size (width, height) {
var p = proportionalSize(this, width, height)
return this
.rx(new SVGNumber(p.width).divide(2))
.ry(new SVGNumber(p.height).divide(2))
}
|