blob: ba4cdb976e12a330b6099bb2f326907bad8de8b8 (
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
|
SVG.extend(SVG.Element, {
// Add transformations
transform: function(o) {
// Full getter
if (o == null)
return this.ctm().extract()
// Singular getter
else if (typeof o === 'string')
return this.ctm().extract()[o]
// Get current matrix
var matrix = new SVG.Matrix(this)
// Act on matrix
if (o.a != null)
matrix = matrix.multiply(new SVG.Matrix(o))
// Act on rotate
else if (o.rotation)
matrix = matrix.rotate(
o.rotation
, o.cx == null ? this.bbox().cx : o.cx
, o.cy == null ? this.bbox().cy : o.cy
)
// Act on scale
else if (o.scale != null || o.scaleX != null || o.scaleY != null)
matrix = matrix.scale(
o.scale != null ? o.scale : o.scaleX != null ? o.scaleX : 1
, o.scale != null ? o.scale : o.scaleY != null ? o.scaleY : 1
, o.cx != null ? o.cx : this.bbox().x
, o.cy != null ? o.cy : this.bbox().y
)
// Act on skew
else if (o.skewX || o.skewY)
matrix = matrix.skew(o.skewX, o.skewY)
// Act on translate
else if (o.x || o.y)
matrix = matrix.translate(o.x, o.y)
return this.attr('transform', matrix)
}
// Reset all transformations
, untransform: function() {
return this.attr('transform', null)
}
})
|