Transformations are operations on the coordinate system. All the transformations defined within a container (an RVG object or a group) are applied before drawing any shapes or text. All transformations are applied in the order they were defined. Note: This means that
g.translate(10,20).scale(2)
is not the same as
g.scale(2).translate(10,20)
Applies the transformation matrix [sx, rx, ry, sy, tx, ty]
# File lib/rvg/transformable.rb, line 46 46: def matrix(sx, rx, ry, sy, tx, ty) 47: begin 48: @transforms << [:affine, [Float(sx), Float(rx), Float(ry), Float(sy), Float(tx), Float(ty)]] 49: rescue ArgumentError 50: raise ArgumentError, "arguments must be convertable to float (got #{sx.class}, #{rx.class}, #{ry.class}, #{sy.class}, #{sx.class}, #{sx.class}, #{tx.class}, #{ty.class})" 51: end 52: yield(self) if block_given? 53: self 54: end
This method can take either of two argument lists:
rotate by angle degrees
rotate by angle degrees about the point [cx, cy].
# File lib/rvg/transformable.rb, line 87 87: def rotate(angle, *args) 88: begin 89: case args.length 90: when 0 91: @transforms << [:rotate, [Float(angle)]] 92: when 2 93: cx, cy = Float(args[0]), Float(args[1]) 94: @transforms << [:translate, [cx, cy]] 95: @transforms << [:rotate, [angle]] 96: @transforms << [:translate, [-cx, -cy]] 97: else 98: raise ArgumentError, "wrong number of arguments (#{args.length} for 1 or 3)" 99: end 100: rescue ArgumentError 101: raise ArgumentError, "arguments must be convertable to float (got #{[angle, *args].collect {|a| a.class}.join(', ')})" 102: end 103: yield(self) if block_given? 104: self 105: end
Multiply the x-coordinates by sx and the y-coordinates by sy. If sy is omitted it defaults to sx.
# File lib/rvg/transformable.rb, line 72 72: def scale(sx, sy=nil) 73: sy ||= sx 74: begin 75: @transforms << [:scale, [Float(sx), Float(sy)]] 76: rescue ArgumentError 77: raise ArgumentError, "arguments must be convertable to float (got #{sx.class}, #{sy.class})" 78: end 79: yield(self) if block_given? 80: self 81: end
Skew the X-axis by angle degrees.
# File lib/rvg/transformable.rb, line 108 108: def skewX(angle) 109: begin 110: @transforms << [:skewx, [Float(angle)]] 111: rescue ArgumentError 112: raise ArgumentError, "argument must be convertable to float (got #{angle.class})" 113: end 114: yield(self) if block_given? 115: self 116: end
Skew the Y-axis by angle degrees.
# File lib/rvg/transformable.rb, line 119 119: def skewY(angle) 120: begin 121: @transforms << [:skewy, [Float(angle)]] 122: rescue ArgumentError 123: raise ArgumentError, "argument must be convertable to float (got #{angle.class})" 124: end 125: yield(self) if block_given? 126: self 127: end
Add tx to all x-coordinates and ty to all y-coordinates. If ty is omitted it defaults to tx.
# File lib/rvg/transformable.rb, line 59 59: def translate(tx, ty=nil) 60: ty ||= tx 61: begin 62: @transforms << [:translate, [Float(tx), Float(ty)]] 63: rescue ArgumentError 64: raise ArgumentError, "arguments must be convertable to float (got #{tx.class}, #{ty.class})" 65: end 66: yield(self) if block_given? 67: self 68: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.