Class: Texture2D
- Inherits:
-
Object
- Object
- Texture2D
- Defined in:
- src/ruby/models/texture2d.rb,
mrb_doc/models/texture2d.rb
Overview
The Texture2D class is most often used for drawing sprites.
Defined Under Namespace
Classes: NotFoundError
Texture filters collapse
- NO_FILTER =
No filter, just pixel approximation.
0- BILINEAR =
Linear filtering.
1- TRILINEAR =
Trilinear filtering (linear with mipmaps).
2- ANISOTROPIC_4X =
Anisotropic filtering 4x.
3- ANISOTROPIC_8X =
Anisotropic filtering 8x.
4- ANISOTROPIC_16X =
Anisotropic filtering 16x.
5
Instance Attribute Summary collapse
- #filter ⇒ Integer
- #format ⇒ Integer readonly
- #height ⇒ Integer readonly
- #id ⇒ Integer readonly
- #mipmaps ⇒ Integer readonly
- #width ⇒ Integer readonly
Class Method Summary collapse
-
.mock_return(id: 1, width: 10, height: 15, mipmaps: 2, format: 0) ⇒ String
A method used to generate the mock data for Raylib.
Instance Method Summary collapse
-
#draw(source: Rectangle[0, 0, width, height], position: Vector2[0, 0], destination: Rectangle[position.x, position.y, source.width, source.height], origin: Vector2[0, 0], rotation: 0, colour: Colour::WHITE) ⇒ nil
Draws the Texture2D segment defined by source at the given destination, rotated around the origin in the specified colour.
- #generate_mipmaps ⇒ nil
-
#initialize(path) ⇒ Texture2D
constructor
Loads an image file from the disk.
-
#to_h ⇒ Hash
Return the object represented by a Hash.
-
#unload ⇒ nil
Unloads the Texture2D from memory.
-
#valid? ⇒ Boolean
Checks if the Texture2D was successfully loaded onto the GPU and is valid.
Constructor Details
#initialize(path) ⇒ Texture2D
Loads an image file from the disk. If the file does not exist, it will raise a NotFoundError error.
11 12 13 14 |
# File 'mrb_doc/models/texture2d.rb', line 11 def initialize(path) # mrb_Texture2D_initialize # src/mruby_integration/models/texture2d.cpp end |
Instance Attribute Details
#filter ⇒ Integer
4 5 6 |
# File 'src/ruby/models/texture2d.rb', line 4 def filter @filter end |
#format ⇒ Integer (readonly)
4 5 6 |
# File 'src/ruby/models/texture2d.rb', line 4 def format @format end |
#height ⇒ Integer (readonly)
4 5 6 |
# File 'src/ruby/models/texture2d.rb', line 4 def height @height end |
#id ⇒ Integer (readonly)
4 5 6 |
# File 'src/ruby/models/texture2d.rb', line 4 def id @id end |
#mipmaps ⇒ Integer (readonly)
4 5 6 |
# File 'src/ruby/models/texture2d.rb', line 4 def mipmaps @mipmaps end |
#width ⇒ Integer (readonly)
4 5 6 |
# File 'src/ruby/models/texture2d.rb', line 4 def width @width end |
Class Method Details
.mock_return(id: 1, width: 10, height: 15, mipmaps: 2, format: 0) ⇒ String
A method used to generate the mock data for Raylib.
32 33 34 |
# File 'src/ruby/models/texture2d.rb', line 32 def self.mock_return(id: 1, width: 10, height: 15, mipmaps: 2, format: 0) [id, width, height, mipmaps, format].map(&:to_s).join(" ") end |
Instance Method Details
#draw(source: Rectangle[0, 0, width, height], position: Vector2[0, 0], destination: Rectangle[position.x, position.y, source.width, source.height], origin: Vector2[0, 0], rotation: 0, colour: Colour::WHITE) ⇒ nil
Draws the Texture2D segment defined by source at the given destination, rotated around the origin in the specified colour.
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'mrb_doc/models/texture2d.rb', line 123 def draw( source: Rectangle[0, 0, width, height], position: Vector2[0, 0], destination: Rectangle[position.x, position.y, source.width, source.height], origin: Vector2[0, 0], rotation: 0, colour: Colour::WHITE ) # mrb_Texture2D_draw # src/mruby_integration/models/texture2d.cpp nil end |
#generate_mipmaps ⇒ nil
74 75 76 77 78 |
# File 'mrb_doc/models/texture2d.rb', line 74 def generate_mipmaps # mrb_Texture2D_generate_mipmaps # src/mruby_integration/models/texture2d.cpp nil end |
#to_h ⇒ Hash
Return the object represented by a Hash.
8 9 10 11 12 13 14 15 16 |
# File 'src/ruby/models/texture2d.rb', line 8 def to_h { id: id, width: width, height: height, mipmaps: mipmaps, format: format } end |
#unload ⇒ nil
Unloads the Texture2D from memory.
23 24 25 26 27 |
# File 'mrb_doc/models/texture2d.rb', line 23 def unload # mrb_Texture2D_unload # src/mruby_integration/models/texture2d.cpp nil end |
#valid? ⇒ Boolean
Checks if the Texture2D was successfully loaded onto the GPU and is valid.
37 38 39 40 41 |
# File 'mrb_doc/models/texture2d.rb', line 37 def valid? # mrb_Texture_valid # src/mruby_integration/models/texture.cpp true end |