Class: Texture

Inherits:
LiteRGSS::Bitmap show all
Defined in:
scripts/00000 Dependencies/00001 LiteRGSS2/00000 DataClasses.rb

Overview

Class that stores an image loaded from file or memory into the VRAM

Constant Summary collapse

SUPPORTED_EXTS =

List of supported extensions

%w[.png .PNG .jpg]

Instance Attribute Summary

Attributes inherited from LiteRGSS::Bitmap

#height, #rect, #width

Instance Method Summary collapse

Methods inherited from LiteRGSS::Bitmap

new, #to_png, #to_png_file, #update

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(filename, from_mem = nil) ⇒ Texture

Initialize the texture, add automatically the extension to the filename

Parameters:

  • filename (String)

    Filename or FileData

  • from_mem (Boolean) (defaults to: nil)

    load the file from memory (then filename is FileData)



22
23
24
25
26
27
28
29
30
# File 'scripts/00000 Dependencies/00001 LiteRGSS2/00000 DataClasses.rb', line 22

def initialize(filename, from_mem = nil)
  if from_mem || File.exist?(filename)
    super
  elsif (new_filename = SUPPORTED_EXTS.map { |e| filename + e }.find { |f| File.exist?(f) })
    super(new_filename)
  else
    super(16, 16)
  end
end