class SFML::Vertex
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])
Attributes
The position, color, tex coords components.
The position, color, tex coords components.
The position, color, tex coords components.
Public Class Methods
Source
# File lib/sfml/graphics/vertex.rb, line 40 def self.from_native(struct) new( Vector2.new(struct[:position][:x], struct[:position][:y]), color: Color.new(struct[:color][:r], struct[:color][:g], struct[:color][:b], struct[:color][:a]), tex_coords: Vector2.new(struct[:tex_coords][:x], struct[:tex_coords][:y]), ) end
@!visibility private
Source
# 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
Public Instance Methods
Source
# File lib/sfml/graphics/vertex.rb, line 26 def to_native v = C::Graphics::Vertex.new v[:position][:x] = @position.x.to_f v[:position][:y] = @position.y.to_f v[:color][:r] = @color.r v[:color][:g] = @color.g v[:color][:b] = @color.b v[:color][:a] = @color.a v[:tex_coords][:x] = @tex_coords.x.to_f v[:tex_coords][:y] = @tex_coords.y.to_f v end
@!visibility private