# struct `SF::Vertex`inherits `Struct`#

Define a point with color and texture coordinates

A vertex is an improved point. It has a position and other extra attributes that will be used for drawing: in SFML, vertices also have a color and a pair of texture coordinates.

The vertex is the building block of drawing. Everything which is visible on screen is made of vertices. They are grouped as 2D primitives (triangles, quads, ...), and these primitives are grouped to create even more complex 2D entities such as sprites, texts, etc.

If you use the graphical entities of SFML (sprite, text, shape) you won't have to deal with vertices directly. But if you want to define your own 2D entities, such as tiled maps or particle systems, using vertices will allow you to get maximum performances.

Example:

``````# define a 100x100 square, red, with a 10x10 texture mapped on it
vertices = [
SF::Vertex.new(SF.vector2f(  0,   0), SF::Color::Red, SF.vector2f( 0,  0)),
SF::Vertex.new(SF.vector2f(  0, 100), SF::Color::Red, SF.vector2f( 0, 10)),
SF::Vertex.new(SF.vector2f(100, 100), SF::Color::Red, SF.vector2f(10, 10)),
SF::Vertex.new(SF.vector2f(100,   0), SF::Color::Red, SF.vector2f(10,  0)),
]

# draw it
``````

Note: although texture coordinates are supposed to be an integer amount of pixels, their type is float because of some buggy graphics drivers that are not able to process integer coordinates correctly.

See also: `SF::VertexArray`

## Class methods#

### ``` .new(position : Vector2 | Tuple, color : Color, tex_coords : Vector2 | Tuple) ```#

Construct the vertex from its position, color and texture coordinates

• position - Vertex position
• color - Vertex color
• tex_coords - Vertex texture coordinates
View source

### ``` .new(position : Vector2 | Tuple, color : Color) ```#

Construct the vertex from its position and color

The texture coordinates are (0, 0).

• position - Vertex position
• color - Vertex color
View source

### ``` .new(position : Vector2 | Tuple, tex_coords : Vector2 | Tuple) ```#

Construct the vertex from its position and texture coordinates

The vertex color is white.

• position - Vertex position
• tex_coords - Vertex texture coordinates
View source

### ``` .new(position : Vector2 | Tuple) ```#

Construct the vertex from its position

The vertex color is white and texture coordinates are (0, 0).

• position - Vertex position
View source

### ``` .new ```#

Default constructor

View source

## Methods#

### ``` #color : Color ```#

Color of the vertex

View source

View source

### ``` #dup : Vertex ```#

Returns a shallow copy of this object.

Because `Value` is a value type, this method returns `self`, which already involves a shallow copy of this object because value types are passed by value.

View source

### ``` #position : Vector2f ```#

2D position of the vertex

View source

View source

### ``` #tex_coords : Vector2f ```#

Coordinates of the texture's pixel to map to the vertex

View source

View source