Class: Magick::RVG::Use

Inherits:
Object
  • Object
show all
Includes:
Duplicatable, Stylable, Transformable
Defined in:
lib/rvg/container.rb

Overview

A Use object allows the re-use of RVG and RVG::Group objects within a container. Create a Use object with the RVG::UseConstructors#use method.

Instance Method Summary collapse

Methods included from Duplicatable

#deep_copy

Methods included from Transformable

#matrix, #rotate, #scale, #skewX, #skewY, #translate

Methods included from Stylable

#styles

Constructor Details

#initialize(element, x = 0, y = 0, width = nil, height = nil) ⇒ Use

In a container, Use objects are created indirectly via the RVG::UseConstructors#use method. The x and y arguments can be used to specify an additional translation for the group. The width and height arguments specify a width and height for referenced RVG objects.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/rvg/container.rb', line 99

def initialize(element, x=0, y=0, width=nil, height=nil)
    super()

    # If the element is not a group, defs, symbol, or rvg,
    # wrap a group around it so it can get a transform and
    # possibly a new viewport.
    if !element.respond_to?(:ref)
        @element = Group.new
        @element << element.deep_copy
    else
        @element = element.deep_copy
    end
    @element.ref(x, y, width, height)
end

Instance Method Details

#add_primitives(gc) ⇒ Object

:nodoc:



114
115
116
117
118
119
120
# File 'lib/rvg/container.rb', line 114

def add_primitives(gc)      #:nodoc:
    gc.push
    add_transform_primitives(gc)
    add_style_primitives(gc)
    @element.add_primitives(gc)
    gc.pop
end