Class: Magick::RVG::TextBase
- Inherits:
-
Object
- Object
- Magick::RVG::TextBase
- Includes:
- Duplicatable, Stylable
- Defined in:
- lib/rvg/text.rb
Overview
Base class for Tspan, Tref and Text.
Instance Method Summary collapse
-
#add_primitives(gc) ⇒ Object
We do our own transformations.
-
#d(x, y = 0) {|_self| ... } ⇒ Object
Add
x
andy
to the current text position. -
#rotate(degrees) {|_self| ... } ⇒ Object
Rotate the text about the current text position.
-
#tspan(text, x = nil, y = nil) ⇒ Object
Create a new text chunk.
Methods included from Duplicatable
Methods included from Stylable
Instance Method Details
#add_primitives(gc) ⇒ Object
We do our own transformations.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rvg/text.rb', line 52 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 |
#d(x, y = 0) {|_self| ... } ⇒ Object
Add x
and y
to the current text position.
38 39 40 41 42 |
# File 'lib/rvg/text.rb', line 38 def d(x, y=0) @dx, @dy = Magick::RVG.convert_to_float(x, y) yield(self) if block_given? self end |
#rotate(degrees) {|_self| ... } ⇒ Object
Rotate the text about the current text position.
45 46 47 48 49 |
# File 'lib/rvg/text.rb', line 45 def rotate(degrees) @rotation = Magick::RVG.convert_to_float(degrees)[0] yield(self) if block_given? self end |
#tspan(text, x = nil, y = nil) ⇒ Object
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.
30 31 32 33 34 35 |
# File 'lib/rvg/text.rb', line 30 def tspan(text, x=nil, y=nil) tspan = Tspan.new(text, x, y) tspan.parent = self @tspans << tspan tspan end |