Sha256: 93ce53b5c7df4c19f80f2385a4eeaf14bb6aa85c461b5fd449b5eb149a2ddd8e

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

module Processing


  # Font object.
  #
  class Font

    # @private
    def initialize(font)
      @font = font
    end

    # Returns bounding box.
    #
    # @overload textBounds(str)
    # @overload textBounds(str, x, y)
    # @overload textBounds(str, x, y, fontSize)
    #
    # @param str      [String]  text to calculate bounding box
    # @param x        [Numeric] horizontal position of bounding box
    # @param y        [Numeric] vertical position of bounding box
    # @param fontSize [Numeric] font size
    #
    # @return [TextBounds] bounding box for text
    #
    def textBounds(str, x = 0, y = 0, fontSize = nil)
      f = fontSize ? Rays::Font.new(@font.name, fontSize) : @font
      TextBounds.new x, y, x + f.width(str), y + f.height
    end

  end# Font


  # Bounding box for text.
  #
  class TextBounds

    # Horizontal position
    #
    attr_reader :x

    # Vertical position
    #
    attr_reader :y

    # Width of bounding box
    #
    attr_reader :w

    # Height of bounding box
    #
    attr_reader :h

    # @private
    def initialize(x, y, w, h)
      @x, @y, @w, @h = x, y, w, h
    end

  end# TextBounds


end# Processing

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
processing-0.5.5 lib/processing/font.rb
processing-0.5.4 lib/processing/font.rb
processing-0.5.3 lib/processing/font.rb
processing-0.5.2 lib/processing/font.rb
processing-0.5.1 lib/processing/font.rb
processing-0.5.0 lib/processing/font.rb