Class: Processing::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/processing/font.rb

Overview

Font object.

Instance Method Summary collapse

Instance Method Details

#inspectString

Returns a string containing a human-readable representation of object.

Returns:

  • (String)

    inspected text



35
36
37
# File 'lib/processing/font.rb', line 35

def inspect()
  "#<Processing::Font: name:'#{@font.name}' size:#{@font.size}>"
end

#textBounds(str) ⇒ TextBounds #textBounds(str, x, y) ⇒ TextBounds #textBounds(str, x, y, fontSize) ⇒ TextBounds

Returns bounding box.

Parameters:

  • str (String)

    text to calculate bounding box

  • x (Numeric) (defaults to: 0)

    horizontal position of bounding box

  • y (Numeric) (defaults to: 0)

    vertical position of bounding box

  • fontSize (Numeric) (defaults to: nil)

    font size

Returns:



26
27
28
29
# File 'lib/processing/font.rb', line 26

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