Class: Assimp::EmbeddedTexture

Inherits:
Object
  • Object
show all
Defined in:
lib/assimp/embedded_texture.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width:, height:, format_hint:, filename:, bytes:) ⇒ EmbeddedTexture

Returns a new instance of EmbeddedTexture.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/assimp/embedded_texture.rb', line 7

def initialize(width:, height:, format_hint:, filename:, bytes:)
  @width = Integer(width)
  @height = Integer(height)
  @format_hint = String(format_hint).dup.freeze
  @filename = String(filename).dup.freeze
  @bytes = String(bytes).dup.force_encoding(Encoding::BINARY).freeze
  expected = compressed? ? @width : @width * @height * 4
  raise ArgumentError, "texture has #{@bytes.bytesize} bytes, expected #{expected}" unless @bytes.bytesize == expected

  freeze
end

Instance Attribute Details

#bytesObject (readonly)

Returns the value of attribute bytes.



5
6
7
# File 'lib/assimp/embedded_texture.rb', line 5

def bytes
  @bytes
end

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/assimp/embedded_texture.rb', line 5

def filename
  @filename
end

#format_hintObject (readonly)

Returns the value of attribute format_hint.



5
6
7
# File 'lib/assimp/embedded_texture.rb', line 5

def format_hint
  @format_hint
end

#heightObject (readonly)

Returns the value of attribute height.



5
6
7
# File 'lib/assimp/embedded_texture.rb', line 5

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



5
6
7
# File 'lib/assimp/embedded_texture.rb', line 5

def width
  @width
end

Instance Method Details

#compressed?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/assimp/embedded_texture.rb', line 19

def compressed?
  height.zero?
end