### Home Classes Methods

### In Files

- lib/rvg/misc.rb

### Parent

Object

### Methods

- ::degrees_to_radians
- ::new
- #affine
- #baseline_shift
- #font
- #font_family
- #font_size
- #font_stretch
- #font_style
- #font_weight
- #glyph_orientation_horizontal
- #glyph_orientation_vertical
- #inspect
- #letter_spacing
- #method_missing
- #pop
- #push
- #rotate
- #scale
- #shadow
- #skewX
- #skewY
- #stroke_width
- #text
- #text_anchor
- #text_decoration
- #translate
- #word_spacing
- #writing_mode

### Files

- MANIFEST
- Makefile

### Class/Module Index

Quicksearch

- Magick
- Magick::DestroyedImageError
- Magick::Draw
- Magick::Enum
- Magick::FatalImageMagickError
- Magick::Geometry
- Magick::GeometryValue
- Magick::GradientFill
- Magick::HatchFill
- Magick::IPTC
- Magick::IPTC::Application
- Magick::IPTC::Envelope
- Magick::IPTC::ObjectData
- Magick::IPTC::Post_ObjectData_Descriptor
- Magick::IPTC::Pre_ObjectData_Descriptor
- Magick::Image
- Magick::Image::DrawOptions
- Magick::Image::Info
- Magick::Image::PolaroidOptions
- Magick::Image::View
- Magick::Image::View::Pixels
- Magick::Image::View::Rows
- Magick::ImageList
- Magick::ImageList::Montage
- Magick::ImageMagickError
- Magick::OptionalMethodArguments
- Magick::Pixel
- Magick::RVG
- Magick::RVG::Circle
- Magick::RVG::ClipPath
- Magick::RVG::Describable
- Magick::RVG::Duplicatable
- Magick::RVG::Ellipse
- Magick::RVG::Embellishable
- Magick::RVG::Group
- Magick::RVG::Image
- Magick::RVG::ImageConstructors
- Magick::RVG::Line
- Magick::RVG::Path
- Magick::RVG::PathData
- Magick::RVG::Pattern
- Magick::RVG::PolyShape
- Magick::RVG::Polygon
- Magick::RVG::Polyline
- Magick::RVG::PreserveAspectRatio
- Magick::RVG::Rect
- Magick::RVG::ShapeConstructors
- Magick::RVG::Stretchable
- Magick::RVG::StructureConstructors
- Magick::RVG::Stylable
- Magick::RVG::Text
- Magick::RVG::TextBase
- Magick::RVG::TextConstructors
- Magick::RVG::Transformable
- Magick::RVG::Use
- Magick::RVG::UseConstructors
- Magick::RVG::Utility
- Magick::RVG::Utility::DefaultTextStrategy
- Magick::RVG::Utility::GraphicContext
- Magick::RVG::Utility::LRTextStrategy
- Magick::RVG::Utility::RLTextStrategy
- Magick::RVG::Utility::TBTextStrategy
- Magick::RVG::Utility::TextAttributes
- Magick::RVG::Utility::TextStrategy
- Magick::TextureFill
- Object

No matching classes.

# Magick::RVG::Utility::GraphicContext

### Constants

ANCHOR_TO_ALIGN
FONT_STRETCH
FONT_STYLE
FONT_WEIGHT
TEXT_ANCHOR
TEXT_DECORATION
TEXT_STRATEGIES

### Attributes

gc[R]
text_attrs[R]

### Public Class Methods

degrees_to_radians(deg) click to toggle source

    # File lib/rvg/misc.rb, line 509
    def GraphicContext.degrees_to_radians(deg)
        Math::PI * (deg % 360.0) / 180.0
    end

new() click to toggle source

    # File lib/rvg/misc.rb, line 537
    def initialize()
        @gc = Magick::Draw.new
        @shadow = Array.new
        @shadow << Magick::Draw.new
        @text_attrs = TextAttributes.new
        init_matrix()
    end

### Public Instance Methods

affine(sx, rx, ry, sy, tx, ty) click to toggle source

    # File lib/rvg/misc.rb, line 549
    def affine(sx, rx, ry, sy, tx, ty)
        sx, rx, ry, sy, tx, ty = Magick::RVG.convert_to_float(sx, rx, ry, sy, tx, ty)
        @gc.affine(sx, rx, ry, sy, tx, ty)
        @text_attrs.set_affine(sx, rx, ry, sy, tx, ty)
        nil
    end

baseline_shift(value) click to toggle source

    # File lib/rvg/misc.rb, line 556
    def baseline_shift(value)
        @text_attrs.baseline_shift = case value
            when 'baseline', 'sub', 'super'
                value.intern
            when /[-+]?\d+%/, Numeric
                value
            else
                :baseline
            end
        nil
    end

font(name) click to toggle source

    # File lib/rvg/misc.rb, line 568
    def font(name)
        @gc.font(name)
        @shadow[-1].font = name
        nil
    end

font_family(name) click to toggle source

    # File lib/rvg/misc.rb, line 574
    def font_family(name)
        @gc.font_family(name)
        @shadow[-1].font_family = name
        nil
    end

font_size(points) click to toggle source

    # File lib/rvg/misc.rb, line 580
    def font_size(points)
        @gc.font_size(points)
        @shadow[-1].pointsize = points
        nil
    end

font_stretch(stretch) click to toggle source

    # File lib/rvg/misc.rb, line 586
    def font_stretch(stretch)
        stretch = FONT_STRETCH.fetch(stretch.intern, Magick::NormalStretch)
        @gc.font_stretch(stretch)
        @shadow[-1].font_stretch = stretch
        nil
    end

font_style(style) click to toggle source

    # File lib/rvg/misc.rb, line 593
    def font_style(style)
        style = FONT_STYLE.fetch(style.intern, Magick::NormalStyle)
        @gc.font_style(style)
        @shadow[-1].font_style = style
        nil
    end

font_weight(weight) click to toggle source

    # File lib/rvg/misc.rb, line 600
    def font_weight(weight)
        # If the arg is not in the hash use it directly. Handles numeric values.
        weight = FONT_WEIGHT.fetch(weight) {|key| key}
        @gc.font_weight(weight)
        @shadow[-1].font_weight = weight
        nil
    end

glyph_orientation_horizontal(deg) click to toggle source

    # File lib/rvg/misc.rb, line 608
    def glyph_orientation_horizontal(deg)
        deg = Magick::RVG.convert_one_to_float(deg)
        @text_attrs.glyph_orientation_horizontal = (deg % 360) / 90 * 90
        nil
    end

glyph_orientation_vertical(deg) click to toggle source

    # File lib/rvg/misc.rb, line 614
    def glyph_orientation_vertical(deg)
        deg = Magick::RVG.convert_one_to_float(deg)
        @text_attrs.glyph_orientation_vertical = (deg % 360) / 90 * 90
        nil
    end

inspect() click to toggle source

    # File lib/rvg/misc.rb, line 620
    def inspect()
        @gc.inspect
    end

letter_spacing(value) click to toggle source

    # File lib/rvg/misc.rb, line 624
    def letter_spacing(value)
        @text_attrs.letter_spacing = Magick::RVG.convert_one_to_float(value)
        nil
    end

method_missing(methID, *args, &block) click to toggle source

    # File lib/rvg/misc.rb, line 545
    def method_missing(methID, *args, &block)
        @gc.__send__(methID, *args, &block)
    end

pop() click to toggle source

    # File lib/rvg/misc.rb, line 636
    def pop()
        @gc.pop
        @shadow.pop
        @text_attrs.pop
        nil
    end

push() click to toggle source

    # File lib/rvg/misc.rb, line 629
    def push()
        @gc.push
        @shadow.push(@shadow.last.dup)
        @text_attrs.push
        nil
    end

rotate(degrees) click to toggle source

    # File lib/rvg/misc.rb, line 643
    def rotate(degrees)
        degrees = Magick::RVG.convert_one_to_float(degrees)
        @gc.rotate(degrees)
        @sx =  Math.cos(GraphicContext.degrees_to_radians(degrees))
        @rx =  Math.sin(GraphicContext.degrees_to_radians(degrees))
        @ry = -Math.sin(GraphicContext.degrees_to_radians(degrees))
        @sy =  Math.cos(GraphicContext.degrees_to_radians(degrees))
        concat_matrix()
        nil
    end

scale(sx, sy) click to toggle source

    # File lib/rvg/misc.rb, line 654
    def scale(sx, sy)
        sx, sy = Magick::RVG.convert_to_float(sx, sy)
        @gc.scale(sx, sy)
        @sx, @sy = sx, sy
        concat_matrix()
        nil
    end

shadow() click to toggle source

    # File lib/rvg/misc.rb, line 662
    def shadow()
        @shadow.last
    end

skewX(degrees) click to toggle source

    # File lib/rvg/misc.rb, line 666
    def skewX(degrees)
        degrees = Magick::RVG.convert_one_to_float(degrees)
        @gc.skewX(degrees)
        @ry = Math.tan(GraphicContext.degrees_to_radians(degrees))
        concat_matrix()
        nil
    end

skewY(degrees) click to toggle source

    # File lib/rvg/misc.rb, line 674
    def skewY(degrees)
        degrees = Magick::RVG.convert_one_to_float(degrees)
        @gc.skewY(degrees)
        @rx = Math.tan(GraphicContext.degrees_to_radians(degrees))
        concat_matrix()
        nil
    end

stroke_width(width) click to toggle source

    # File lib/rvg/misc.rb, line 682
    def stroke_width(width)
        width = Magick::RVG.convert_one_to_float(width)
        @gc.stroke_width(width)
        @shadow[-1].stroke_width = width
        nil
    end

text(x, y, text) click to toggle source

    # File lib/rvg/misc.rb, line 689
    def text(x, y, text)
        return if text.length == 0
        if @text_attrs.non_default?
            text_renderer = TEXT_STRATEGIES[@text_attrs.writing_mode].new(self)
        else
            text_renderer = DefaultTextStrategy.new(self)
        end

        return text_renderer.render(x, y, text)
    end

text_anchor(anchor) click to toggle source

    # File lib/rvg/misc.rb, line 700
    def text_anchor(anchor)
        anchor = anchor.intern
        anchor_enum = TEXT_ANCHOR.fetch(anchor, Magick::StartAnchor)
        @gc.text_anchor(anchor_enum)
        align = ANCHOR_TO_ALIGN.fetch(anchor, Magick::LeftAlign)
        @shadow[-1].align = align
        @text_attrs.text_anchor = anchor
        nil
    end

text_decoration(decoration) click to toggle source

    # File lib/rvg/misc.rb, line 710
    def text_decoration(decoration)
        decoration = TEXT_DECORATION.fetch(decoration.intern, Magick::NoDecoration)
        @gc.decorate(decoration)
        @shadow[-1].decorate = decoration
        nil
    end

translate(tx, ty) click to toggle source

    # File lib/rvg/misc.rb, line 717
    def translate(tx, ty)
        tx, ty = Magick::RVG.convert_to_float(tx, ty)
        @gc.translate(tx, ty)
        @tx, @ty = tx, ty
        concat_matrix()
        nil
    end

word_spacing(value) click to toggle source

    # File lib/rvg/misc.rb, line 725
    def word_spacing(value)
        @text_attrs.word_spacing = Magick::RVG.convert_one_to_float(value)
        nil
    end

writing_mode(mode) click to toggle source

    # File lib/rvg/misc.rb, line 730
    def writing_mode(mode)
        @text_attrs.writing_mode = mode
        nil
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.