Class: Ruby2D::Pixmap

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby2d/pixmap.rb

Overview

A pixmap represents an image made up of pixel data of fixed width and height.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Pixmap

Returns a new instance of Pixmap.



25
26
27
28
29
30
31
32
33
# File 'lib/ruby2d/pixmap.rb', line 25

def initialize(file_path)
  file_path = file_path.to_s
  raise UnknownImageFileError, file_path unless File.exist? file_path

  ext_load_pixmap(file_path)
  raise InvalidImageFileError, file_path unless @ext_pixel_data

  @path = file_path
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



23
24
25
# File 'lib/ruby2d/pixmap.rb', line 23

def height
  @height
end

#pathObject (readonly)

Returns the value of attribute path.



23
24
25
# File 'lib/ruby2d/pixmap.rb', line 23

def path
  @path
end

#widthObject (readonly)

Returns the value of attribute width.



23
24
25
# File 'lib/ruby2d/pixmap.rb', line 23

def width
  @width
end

Instance Method Details

#textureObject



35
36
37
# File 'lib/ruby2d/pixmap.rb', line 35

def texture
  @texture ||= Texture.new(@ext_pixel_data, @width, @height)
end