Sha256: 01ad46123e9bfb0e0f254692bf457fcf7a101de8253f4a7930415a4e01b5bde9
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# Ruby2D::Text module Ruby2D class Text include Renderable attr_reader :text, :size, :width, :height, :font, :color attr_accessor :x, :y, :rotate, :data def initialize(opts = {}) @x = opts[:x] || 0 @y = opts[:y] || 0 @z = opts[:z] || 0 @text = (opts[:text] || "Hello Ruby!").to_s @size = opts[:size] || 20 @rotate = opts[:rotate] || 0 @font = opts[:font] unless RUBY_ENGINE == 'opal' unless File.exists? @font raise Error, "Cannot find font file `#{@font}`" end end self.color = opts[:color] || 'white' ext_init add end def text=(msg) @text = msg.to_s ext_set(@text) end def color=(c) @color = Color.new(c) end def contains?(x, y) @x < x and @x + @width > x and @y < y and @y + @height > y end private def resolve_path(font) if RUBY_PLATFORM =~ /darwin/ font_path = "/Library/Fonts/#{font}.ttf" else # Linux font_path = "/usr/share/fonts/truetype/#{font}.ttf" end unless File.exists? font_path raise Error, "Cannot find system font" else font_path end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby2d-0.6.0 | lib/ruby2d/text.rb |