Class: Texture2D

Inherits:
Object
  • Object
show all
Defined in:
mrb_doc/models/texture2d.rb

Overview

The Texture2D class is most often used for drawing sprites.

Defined Under Namespace

Classes: NotFound

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, width, height, mipmaps, format) ⇒ Texture2D

Creates a new instance of Texture2D

Parameters:

  • id (Integer)
  • width (Integer)
  • height (Integer)
  • mipmaps (Integer)
  • format (Integer)


13
14
15
16
17
# File 'mrb_doc/models/texture2d.rb', line 13

def initialize(id, width, height, mipmaps, format)
  # mrb_Texture2D_initialize
  # src/mruby_integration/models/texture2d.cpp
  Texture2D.new
end

Instance Attribute Details

#formatInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/texture2d.rb', line 4

def format
  @format
end

#heightInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/texture2d.rb', line 4

def height
  @height
end

#idInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/texture2d.rb', line 4

def id
  @id
end

#mipmapsInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/texture2d.rb', line 4

def mipmaps
  @mipmaps
end

#widthInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/texture2d.rb', line 4

def width
  @width
end

Class Method Details

.load(path) ⇒ Texture2D

Loads a texture from the specified path

Parameters:

  • path (String)

Returns:

Raises:



66
67
68
69
# File 'mrb_doc/models/texture2d.rb', line 66

def self.load(path)
  # src/mruby_integration/models/texture2d.cpp
  Texture2D.new
end

Instance Method Details

#draw(source: nil, destination: nil, origin: Vector2::ZERO, rotation: 0, colour: WHITE) ⇒ nil

Draws the texture segment defined by source at the given destination, rotated around the origin in the specified colour. If source is not defined it defaults to the full image. If destination is not defined it defaults to source.

Parameters:

  • source (Rectangle) (defaults to: nil)
  • destination (Rectangle) (defaults to: nil)
  • origin (Vector2) (defaults to: Vector2::ZERO)
  • rotation (Integer) (defaults to: 0)

    in degrees

  • colour (Colour) (defaults to: WHITE)

Returns:

  • (nil)


88
89
90
91
# File 'mrb_doc/models/texture2d.rb', line 88

def draw(source: nil, destination: nil, origin: Vector2::ZERO, rotation:0, colour: WHITE)
  # src/mruby_integration/models/font.cpp
  nil
end

#to_hHash

Return the object represented by a Hash

Returns:

  • (Hash)


51
52
53
54
55
56
57
58
59
60
# File 'mrb_doc/models/texture2d.rb', line 51

def to_h
  # src/mruby_integration/models/texture2d.cpp
  {
    id: id,
    width: width,
    height: height,
    mipmaps: mipmaps,
    format: format,
  }
end

#unloadnil

Unloads the texture from memory

Returns:

  • (nil)


73
74
75
76
# File 'mrb_doc/models/texture2d.rb', line 73

def unload
  # src/mruby_integration/models/texture.cpp
  nil
end