class Magick::RVG::TextBase
Public Class Methods
new(text) { |self| ... }
click to toggle source
Calls superclass method
Magick::RVG::Stylable::new
# File lib/rvg/text.rb, line 15 def initialize(text) super() @text = text.to_s if text @dx = @dy = 0 @rotation = 0 @tspans = Content.new yield(self) if block_given? end
Public Instance Methods
add_primitives(gc)
click to toggle source
We do our own transformations. @private
# File lib/rvg/text.rb, line 52 def add_primitives(gc) return if !@text && @tspans.empty? gc.push x = cx + @dx y = cy + @dy if @rotation != 0 gc.translate(x, y) gc.rotate(@rotation) gc.translate(-x, -y) end add_style_primitives(gc) if @text x2, y2 = gc.text(x, y, @text) self.cx = x + x2 self.cy = y + y2 end @tspans.each do |tspan| tspan.add_primitives(gc) end gc.pop end
d(x, y = 0) { |self| ... }
click to toggle source
Add x
and y
to the current text position.
# File lib/rvg/text.rb, line 37 def d(x, y = 0) @dx, @dy = Magick::RVG.convert_to_float(x, y) yield(self) if block_given? self end
rotate(degrees) { |self| ... }
click to toggle source
Rotate the text about the current text position.
# File lib/rvg/text.rb, line 44 def rotate(degrees) @rotation = Magick::RVG.convert_to_float(degrees)[0] yield(self) if block_given? self end
tspan(text, x = nil, y = nil)
click to toggle source
Create a new text chunk. Each chunk can have its own initial position and styles. If x
and y
are omitted the text starts at the current text position.
# File lib/rvg/text.rb, line 29 def tspan(text, x = nil, y = nil) tspan = Tspan.new(text, x, y) tspan.parent = self @tspans << tspan tspan end