Sha256: c70a7a9be852b98b5e053b249550208764185816e8a59c7869a512f2f2d0542d

Contents?: true

Size: 773 Bytes

Versions: 7

Compression:

Stored size: 773 Bytes

Contents

# Ruby2D::Text

module Ruby2D
  class Text
    include Renderable

    attr_reader :text, :font
    attr_accessor :x, :y, :size, :rotate, :data

    def initialize(text, opts = {})
      @x = opts[:x] || 0
      @y = opts[:y] || 0
      @z = opts[:z] || 0
      @text = text.to_s
      @size = opts[:size] || 20
      @rotate = opts[:rotate] || 0
      self.color = opts[:color] || 'white'
      self.opacity = opts[:opacity] if opts[:opacity]
      @font = opts[:font] || Font.default
      unless File.exist? @font
        raise Error, "Cannot find font file `#{@font}`"
      end
      unless ext_init
        raise Error, "Text `#{@text}` cannot be created"
      end
      add
    end

    def text=(msg)
      @text = msg.to_s
      ext_set(@text)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby2d-0.9.5 lib/ruby2d/text.rb
ruby2d-0.9.4 lib/ruby2d/text.rb
ruby2d-0.9.3 lib/ruby2d/text.rb
ruby2d-0.9.2 lib/ruby2d/text.rb
ruby2d-0.9.1 lib/ruby2d/text.rb
ruby2d-0.9.0 lib/ruby2d/text.rb
ruby2d-0.8.1 lib/ruby2d/text.rb