Class: SFML::Vertex
- Inherits:
-
Object
- Object
- SFML::Vertex
- Defined in:
- lib/sfml/graphics/vertex.rb
Overview
A single point of geometry: position, colour, and texture coordinate. Plain Ruby value object — VertexArray copies it into / out of CSFML storage, so mutating a Vertex after appending doesn’t propagate.
SFML::Vertex.new([10, 20])
SFML::Vertex.new([10, 20], color: SFML::Color.red)
SFML::Vertex.new([10, 20], color: SFML::Color.red, tex_coords: [0, 0])
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#position ⇒ Object
Returns the value of attribute position.
-
#tex_coords ⇒ Object
Returns the value of attribute tex_coords.
Instance Method Summary collapse
-
#initialize(position = Vector2.zero, color: Color::WHITE, tex_coords: Vector2.zero) ⇒ Vertex
constructor
A new instance of Vertex.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(position = Vector2.zero, color: Color::WHITE, tex_coords: Vector2.zero) ⇒ Vertex
Returns a new instance of Vertex.
12 13 14 15 16 |
# File 'lib/sfml/graphics/vertex.rb', line 12 def initialize(position = Vector2.zero, color: Color::WHITE, tex_coords: Vector2.zero) @position = _coerce_vec2(position) @color = color @tex_coords = _coerce_vec2(tex_coords) end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
10 11 12 |
# File 'lib/sfml/graphics/vertex.rb', line 10 def color @color end |
#position ⇒ Object
Returns the value of attribute position.
10 11 12 |
# File 'lib/sfml/graphics/vertex.rb', line 10 def position @position end |
#tex_coords ⇒ Object
Returns the value of attribute tex_coords.
10 11 12 |
# File 'lib/sfml/graphics/vertex.rb', line 10 def tex_coords @tex_coords end |
Instance Method Details
#to_s ⇒ Object Also known as: inspect
18 19 20 |
# File 'lib/sfml/graphics/vertex.rb', line 18 def to_s "Vertex(#{@position.x}, #{@position.y})" end |