Method: Ray::Text#initialize
- Defined in:
- lib/ray/text.rb
#initialize(string, opts = {}) ⇒ Text
Returns a new instance of Text.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ray/text.rb', line 17 def initialize(string, opts = {}) opts = { :encoding => string.respond_to?(:encoding) ? string.encoding : "utf-8", :size => 12, :style => Normal, :at => [0, 0], :angle => 0, :color => Ray::Color.white }.merge(opts) @encoding = opts[:encoding].to_s self.string = string self.size = opts[:size] self.style = opts[:style] self.pos = opts[:at] self.scale = opts[:scale] || opts[:zoom] || [1, 1] self.angle = opts[:angle] self.color = opts[:color] self.shader = opts[:shader] if font = opts[:font] self.font = font.is_a?(String) ? Ray::FontSet[font] : font end end |