Class: SFML::Vertex

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(position = Vector2.zero, color: Color::WHITE, tex_coords: Vector2.zero) ⇒ Vertex

Returns a new instance of Vertex.



13
14
15
16
17
# File 'lib/sfml/graphics/vertex.rb', line 13

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

The position, color, tex coords components.



11
12
13
# File 'lib/sfml/graphics/vertex.rb', line 11

def color
  @color
end

#position ⇒ Object

The position, color, tex coords components.



11
12
13
# File 'lib/sfml/graphics/vertex.rb', line 11

def position
  @position
end

#tex_coords ⇒ Object

The position, color, tex coords components.



11
12
13
# File 'lib/sfml/graphics/vertex.rb', line 11

def tex_coords
  @tex_coords
end

Instance Method Details

#to_s ⇒ Object Also known as: inspect

Returns the to s.



20
21
22
# File 'lib/sfml/graphics/vertex.rb', line 20

def to_s
  "Vertex(#{@position.x}, #{@position.y})"
end