Sha256: 3362dd7e7cc41a2f715dd55ce6c78782aab736bfa3ae3ecebd5ebda85569d346

Contents?: true

Size: 1021 Bytes

Versions: 9

Compression:

Stored size: 1021 Bytes

Contents

class AuthorEngine
  class Text
    include Support
    FONT_DEFAULT      = "#{File.expand_path("../../../", __FILE__)}/assets/fonts/Connection.otf"
    FONT_DEFAULT_BOLD = "#{File.expand_path("../../../", __FILE__)}/assets/fonts/ConnectionBold.otf"

    attr_accessor :message, :x, :y, :z, :color
    attr_reader :size, :font
    def initialize(message: "", size: nil, x: 0, y: 0, z: 0, color: Gosu::Color::WHITE, font: FONT_DEFAULT) # Consolas
      @message = message
      @size = size ? size : (8 * window.scale_y).floor
      @x, @y, @z = x, y, z
      @color, @font_name = color, font

      @font = Gosu::Font.new(@size, name: @font_name)
    end

    def width
      @font.text_width(@message)
    end

    def width_markup
      @font.markup_width(@message)
    end

    def height
      @font.height
    end

    def draw
      @font.draw_text(@message, @x, @y, @z, 1, 1, @color)
    end

    def draw_markup
      @font.draw_markup(@message, @x, @y, @z, 1, 1, @color)
    end

    def update
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
author_engine-0.9.0 lib/author_engine/text.rb
author_engine-0.8.0 lib/author_engine/text.rb
author_engine-0.7.0 lib/author_engine/text.rb
author_engine-0.6.1 lib/author_engine/text.rb
author_engine-0.6.0 lib/author_engine/text.rb
author_engine-0.5.0 lib/author_engine/text.rb
author_engine-0.4.0 lib/author_engine/text.rb
author_engine-0.3.1 lib/author_engine/text.rb
author_engine-0.3.0 lib/author_engine/text.rb