class Magick::RVG::TextBase
Base class for Tspan, Tref and Text.
def add_primitives(gc) #:nodoc:
We do our own transformations.
def add_primitives(gc) #:nodoc: if @text || @tspans.length > 0 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 end
def d(x, y=0)
def d(x, y=0) @dx, @dy = Magick::RVG.convert_to_float(x, y) yield(self) if block_given? self end
def initialize(text, &block) #:nodoc:
def initialize(text, &block) #:nodoc: super() @text = text.to_s if text @dx = @dy = 0 @rotation = 0 @tspans = Content.new yield(self) if block_given? end
def rotate(degrees)
def rotate(degrees) @rotation = Magick::RVG.convert_to_float(degrees)[0] yield(self) if block_given? self end
def tspan(text, x=nil, y=nil)
If x and y are omitted the text starts at the current text
Create a new text chunk. Each chunk can have its own initial position and styles.
def tspan(text, x=nil, y=nil) tspan = Tspan.new(text, x, y) tspan.parent = self @tspans << tspan tspan end