Module: SVGPlot::Transform
- Included in:
- Tag
- Defined in:
- lib/svgplot/transform.rb
Overview
Provide methods for SVG transformations
Instance Method Summary collapse
- #matrix(*args) ⇒ Object
- #rotate(angle, cx = nil, cy = nil) ⇒ Object
- #scale(sx, sy = 1) ⇒ Object
- #skew_x(angle) ⇒ Object
- #skew_y(angle) ⇒ Object
- #translate(tx, ty = 0) ⇒ Object
Instance Method Details
#matrix(*args) ⇒ Object
31 32 33 34 35 |
# File 'lib/svgplot/transform.rb', line 31 def matrix(*args) fail('matrix takes 6 args') unless args.size == 6 add_transform(:matrix, args.join(', ')) self end |
#rotate(angle, cx = nil, cy = nil) ⇒ Object
15 16 17 18 19 |
# File 'lib/svgplot/transform.rb', line 15 def rotate(angle, cx = nil, cy = nil) string = [cx, cy].any?(&:nil?) ? "#{angle}" : "#{angle}, #{cx}, #{cy}" add_transform(:rotate, string) self end |
#scale(sx, sy = 1) ⇒ Object
10 11 12 13 |
# File 'lib/svgplot/transform.rb', line 10 def scale(sx, sy = 1) add_transform(:scale, "#{sx}, #{sy}") self end |
#skew_x(angle) ⇒ Object
21 22 23 24 |
# File 'lib/svgplot/transform.rb', line 21 def skew_x(angle) add_transform(:skewX, "#{angle}") self end |
#skew_y(angle) ⇒ Object
26 27 28 29 |
# File 'lib/svgplot/transform.rb', line 26 def skew_y(angle) add_transform(:skewY, "#{angle}") self end |
#translate(tx, ty = 0) ⇒ Object
5 6 7 8 |
# File 'lib/svgplot/transform.rb', line 5 def translate(tx, ty = 0) add_transform(:translate, "#{tx}, #{ty}") self end |