Module Magick::RVG::Transformable
In: lib/rvg/transformable.rb
Enum GeometryValue Stylable RVG\n[lib/rvg/clippath.rb\nlib/rvg/container.rb\nlib/rvg/deep_equal.rb\nlib/rvg/describable.rb\nlib/rvg/embellishable.rb\nlib/rvg/misc.rb\nlib/rvg/paint.rb\nlib/rvg/pathdata.rb\nlib/rvg/rvg.rb\nlib/rvg/stretchable.rb\nlib/rvg/stylable.rb\nlib/rvg/text.rb\nlib/rvg/transformable.rb\nlib/rvg/units.rb] Transformable Stretchable Embellishable Describable Duplicatable Comparable Image ImageList Enumerable Geometry HatchFill Draw lib/RMagick.rb lib/rvg/rvg.rb ObjectData Application Pre_ObjectData_Descriptor Envelope Post_ObjectData_Descriptor IPTC Magick dot/m_14_0.png

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)

Methods

Public Class methods

[Source]

    # File lib/rvg/transformable.rb, line 38
38:             def initialize(*args, &block)
39:                 super()
40:                 @transforms = Transforms.new
41:             end

Public Instance methods

Applies the transformation matrix [sx, rx, ry, sy, tx, ty]

[Source]

    # 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(angle)
rotate by angle degrees
rotate(angle, cx, cy)
rotate by angle degrees about the point [cx, cy].

[Source]

     # 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.

[Source]

    # 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.

[Source]

     # 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.

[Source]

     # 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.

[Source]

    # 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

Private Instance methods

Apply transforms in the same order they were specified!

[Source]

    # File lib/rvg/transformable.rb, line 34
34:             def add_transform_primitives(gc)
35:                 @transforms.each { |transform| gc.__send__(transform[0], *transform[1]) }
36:             end

[Validate]