Sha256: 82a8856442a1c04b9c11eedf2eee319ed9bc827117a13ae8e58a595f51cec524

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

# image.rb

module Ruby2D
  class Image
    
    attr_accessor :x, :y, :width, :height, :data
    attr_reader :path, :color
    
    def initialize(x, y, path)
      
      # TODO: Check if file exists
      #   `File.exists?` is not available in MRuby
      #   Ideally would do:
      #     unless File.exists? path
      #       raise Error, "Cannot find image file `#{path}`"
      #     end
      
      @type_id = 3
      @x, @y, @path = x, y, path
      @color = Color.new([1, 1, 1, 1])
      init(path)
      add
    end
    
    def color=(c)
      @color = Color.new(c)
    end
    
    def add
      if Module.const_defined? :DSL
        Application.add(self)
      end
    end
    
    def remove
      if Module.const_defined? :DSL
        Application.remove(self)
      end
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby2d-0.3.1 lib/ruby2d/image.rb
ruby2d-0.3.0 lib/ruby2d/image.rb