Class: Magick::RVG::Text

Inherits:
TextBase show all
Defined in:
lib/rvg/text.rb

Overview

class Tspan

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TextBase

#add_primitives, #d, #rotate, #tspan

Methods included from Duplicatable

#deep_copy

Methods included from Stylable

#styles

Constructor Details

#initialize(x = 0, y = 0, text = nil, &block) ⇒ Text

Define a text string starting at [x, y]. Use the RVG::TextConstructors#text method to create Text objects in a container.

container.text(100, 100, "Simple text").styles(:font=>'Arial')

Text objects can contain Tspan objects.

container.text(100, 100).styles(:font=>'Arial') do |t|
   t.tspan("Red text").styles(:fill=>'red')
   t.tspan("Blue text").styles(:fill=>'blue')
end


141
142
143
144
# File 'lib/rvg/text.rb', line 141

def initialize(x=0, y=0, text=nil, &block)
    @cx, @cy = Magick::RVG.convert_to_float(x, y)
    super(text, &block)
end

Instance Attribute Details

#cxObject

:nodoc:



128
129
130
# File 'lib/rvg/text.rb', line 128

def cx
  @cx
end

#cyObject

:nodoc:



128
129
130
# File 'lib/rvg/text.rb', line 128

def cy
  @cy
end

Instance Method Details

#tref(obj, x = nil, y = nil) ⇒ Object

Reference a Tspan object. x and y are just like x and y in RVG::TextBase#tspan



148
149
150
151
152
153
154
155
156
157
# File 'lib/rvg/text.rb', line 148

def tref(obj, x=nil, y=nil)
    unless obj.is_a?(Tspan)
        fail ArgumentError, "wrong argument type #{obj.class} (expected Tspan)"
    end
    obj = obj.deep_copy
    obj.parent = self
    tref = Tref.new(obj, x, y, self)
    @tspans << tref
    tref
end