### Home Classes Methods

### In Files

- lib/rvg/transformable.rb

### Methods

- ::new
- #matrix
- #rotate
- #scale
- #skewX
- #skewY
- #translate

### Files

- MANIFEST
- Makefile

### Class/Module Index

Quicksearch

- Magick
- Magick::DestroyedImageError
- Magick::Draw
- Magick::Enum
- Magick::FatalImageMagickError
- Magick::Geometry
- Magick::GeometryValue
- Magick::GradientFill
- Magick::HatchFill
- Magick::IPTC
- Magick::IPTC::Application
- Magick::IPTC::Envelope
- Magick::IPTC::ObjectData
- Magick::IPTC::Post_ObjectData_Descriptor
- Magick::IPTC::Pre_ObjectData_Descriptor
- Magick::Image
- Magick::Image::DrawOptions
- Magick::Image::Info
- Magick::Image::PolaroidOptions
- Magick::Image::View
- Magick::Image::View::Pixels
- Magick::Image::View::Rows
- Magick::ImageList
- Magick::ImageList::Montage
- Magick::ImageMagickError
- Magick::OptionalMethodArguments
- Magick::Pixel
- Magick::RVG
- Magick::RVG::Circle
- Magick::RVG::ClipPath
- Magick::RVG::Describable
- Magick::RVG::Duplicatable
- Magick::RVG::Ellipse
- Magick::RVG::Embellishable
- Magick::RVG::Group
- Magick::RVG::Image
- Magick::RVG::ImageConstructors
- Magick::RVG::Line
- Magick::RVG::Path
- Magick::RVG::PathData
- Magick::RVG::Pattern
- Magick::RVG::PolyShape
- Magick::RVG::Polygon
- Magick::RVG::Polyline
- Magick::RVG::PreserveAspectRatio
- Magick::RVG::Rect
- Magick::RVG::ShapeConstructors
- Magick::RVG::Stretchable
- Magick::RVG::StructureConstructors
- Magick::RVG::Stylable
- Magick::RVG::Text
- Magick::RVG::TextBase
- Magick::RVG::TextConstructors
- Magick::RVG::Transformable
- Magick::RVG::Use
- Magick::RVG::UseConstructors
- Magick::RVG::Utility
- Magick::RVG::Utility::DefaultTextStrategy
- Magick::RVG::Utility::GraphicContext
- Magick::RVG::Utility::LRTextStrategy
- Magick::RVG::Utility::RLTextStrategy
- Magick::RVG::Utility::TBTextStrategy
- Magick::RVG::Utility::TextAttributes
- Magick::RVG::Utility::TextStrategy
- Magick::TextureFill
- Object

No matching classes.

# Magick::RVG::Transformable

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)

### Public Class Methods

new(*args, &block) click to toggle source

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

### Public Instance Methods

matrix(sx, rx, ry, sy, tx, ty) click to toggle source

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

    # File lib/rvg/transformable.rb, line 46
    def matrix(sx, rx, ry, sy, tx, ty)
        begin
            @transforms << [:affine, [Float(sx), Float(rx), Float(ry), Float(sy), Float(tx), Float(ty)]]
        rescue ArgumentError
            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})"
        end
        yield(self) if block_given?
        self
    end

rotate(angle, *args) click to toggle source

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`].

    # File lib/rvg/transformable.rb, line 87
    def rotate(angle, *args)
        begin
            case args.length
                when 0
                    @transforms << [:rotate, [Float(angle)]]
                when 2
                    cx, cy = Float(args[0]), Float(args[1])
                    @transforms << [:translate, [cx, cy]]
                    @transforms << [:rotate, [angle]]
                    @transforms << [:translate, [-cx, -cy]]
                else
                    raise ArgumentError, "wrong number of arguments (#{args.length} for 1 or 3)"
            end
        rescue ArgumentError
            raise ArgumentError, "arguments must be convertable to float (got #{[angle, *args].collect {|a| a.class}.join(', ')})"
        end
        yield(self) if block_given?
        self
    end

scale(sx, sy=nil) click to toggle source

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
    def scale(sx, sy=nil)
        sy ||= sx
        begin
            @transforms << [:scale, [Float(sx), Float(sy)]]
        rescue ArgumentError
            raise ArgumentError, "arguments must be convertable to float (got #{sx.class}, #{sy.class})"
        end
        yield(self) if block_given?
        self
    end

skewX(angle) click to toggle source

Skew the X-axis by `angle` degrees.

    # File lib/rvg/transformable.rb, line 108
    def skewX(angle)
        begin
            @transforms << [:skewx, [Float(angle)]]
        rescue ArgumentError
            raise ArgumentError, "argument must be convertable to float (got #{angle.class})"
        end
        yield(self) if block_given?
        self
    end

skewY(angle) click to toggle source

Skew the Y-axis by `angle` degrees.

    # File lib/rvg/transformable.rb, line 119
    def skewY(angle)
        begin
            @transforms << [:skewy, [Float(angle)]]
        rescue ArgumentError
            raise ArgumentError, "argument must be convertable to float (got #{angle.class})"
        end
        yield(self) if block_given?
        self
    end

translate(tx, ty=nil) click to toggle source

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
    def translate(tx, ty=nil)
        ty ||= tx
        begin
            @transforms << [:translate, [Float(tx), Float(ty)]]
        rescue ArgumentError
            raise ArgumentError, "arguments must be convertable to float (got #{tx.class}, #{ty.class})"
        end
        yield(self) if block_given?
        self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.