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.



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

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#positionObject

Returns the value of attribute position.



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

def position
  @position
end

#tex_coordsObject

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_sObject Also known as: inspect



18
19
20
# File 'lib/sfml/graphics/vertex.rb', line 18

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