Vertex Instructions

This module include all the classes for drawing simple vertex object.

class kivy.graphics.vertex_instructions.Triangle

Bases: kivy.graphics.instructions.VertexInstruction

A 2d triangle.

Parameters :
points: list

List of point in the format (x1, y1, x2, y2, x3, y3)

points

Property for getting/settings points of the triangle

class kivy.graphics.vertex_instructions.Quad

Bases: kivy.graphics.instructions.VertexInstruction

A 2d quad.

Parameters :
points: list

List of point in the format (x1, y1, x2, y2, x3, y3, x4, y4)

points

Property for getting/settings points of the quads

class kivy.graphics.vertex_instructions.Rectangle

Bases: kivy.graphics.instructions.VertexInstruction

A 2d rectangle.

Parameters :
pos: list

Position of the rectangle, in the format (x, y)

size: list

Size of the rectangle, in the format (width, height)

pos

Property for getting/settings the position of the rectangle

size

Property for getting/settings the size of the rectangle

class kivy.graphics.vertex_instructions.BorderImage

Bases: kivy.graphics.vertex_instructions.Rectangle

A 2d border image. The behavior of the border image is similar to the concept of CSS3 border-image.

Parameters :
border: list

Border information in the format (top, right, bottom, left). Each value is in pixels.

border

Property for getting/setting the border of the class

class kivy.graphics.vertex_instructions.Ellipse

Bases: kivy.graphics.vertex_instructions.Rectangle

A 2D ellipse.

New in version 1.0.7: added angle_start + angle_end

Parameters :
segments: int, default to 180

Define how much segment is needed for drawing the ellipse. The drawing will be smoother if you have lot of segment.

angle_start: int default to 0

Specifies the starting angle, in degrees, of the disk portion

angle_end: int default to 360

Specifies the ending angle, in degrees, of the disk portion

angle_end

Angle end of the ellipse in degrees, default to 360

angle_start

Angle start of the ellipse in degrees, default to 0

segments

Property for getting/setting the number of segments of the ellipse

class kivy.graphics.vertex_instructions.Line

Bases: kivy.graphics.instructions.VertexInstruction

A 2d line.

New in version 1.0.8: dash_offset and dash_length have been added

Parameters :
points: list

List of points in the format (x1, y1, x2, y2...)

dash_length: int

length of a segment (if dashed), default 1

dash_offset: int

offset between the end of a segments and the begining of the next one, default 0, changing this makes it dashed.

dash_length

Property for getting/setting the length of the dashes in the curve

New in version 1.0.8.

dash_offset

Property for getting/setting the offset between the dashes in the curve

New in version 1.0.8.

points

Property for getting/settings points of the line

Warning

This will always reconstruct the whole graphics from the new points list. It can be very CPU expensive.

class kivy.graphics.vertex_instructions.Point

Bases: kivy.graphics.instructions.VertexInstruction

A 2d line.

Parameters :
points: list

List of points in the format (x1, y1, x2, y2...)

pointsize: float, default to 1.

Size of the point (1. mean the real size will be 2)

Warning

Starting from version 1.0.7, vertex instruction have a limit of 65535 vertices (indices of vertex to be accurate). 2 entry in the list (x + y) will be converted to 4 vertices. So the limit inside Point() class is 2^15-2.

add_point()

Add a point into the current points list.

If you intend to add multiple point, prefer to use this method, instead of reassign a new points list. Assigning a new points list will recalculate and reupload the whole buffer into GPU. If you use add_point, it will only upload the changes.

points

Property for getting/settings points of the triangle

pointsize

Property for getting/setting point size

class kivy.graphics.vertex_instructions.Mesh

Bases: kivy.graphics.instructions.VertexInstruction

A 2d mesh.

The format of vertices are actually fixed, this might change in a future release. Right now, each vertex is described with 2D coordinates (x, y) and a 2D texture coordinate (u, v).

In OpenGL ES 2.0 and in our graphics implementation, you cannot have more than 65535 indices.

A list of vertices is described as:

vertices = [x1, y1, u1, v1, x2, y2, u2, v2, ...]
            |            |  |            |
            +---- i1 ----+  +---- i2 ----+

If you want to draw a triangles, put 3 vertices, then you can make an indices list as:

indices = [0, 1, 2]

New in version 1.1.0.

Parameters :
vertices: list

List of vertices in the format (x1, y1, u1, v1, x2, y2, u2, v2...)

indices: list

List of indices in the format (i1, i2, i3...)

mode: str

Mode of the vbo. Check mode for more information. Default to ‘points’.

indices

Vertex indices used to know which order you wanna do for drawing the mesh.

mode

VBO Mode used for drawing vertices/indices. Can be one of: ‘points’, ‘line_strip’, ‘line_loop’, ‘lines’, ‘triangle_strip’, ‘triangle_fan’

vertices

List of x, y, u, v, ... used to construct the Mesh. Right now, the Mesh instruction doesn’t allow you to change the format of the vertices, mean it’s only x/y + one texture coordinate.

class kivy.graphics.vertex_instructions.GraphicException

Bases: exceptions.Exception

Exception fired when a graphic error is fired.

class kivy.graphics.vertex_instructions.Bezier

Bases: kivy.graphics.instructions.VertexInstruction

A 2d Bezier curve.

New in version 1.0.8.

Parameters :
points: list

List of points in the format (x1, y1, x2, y2...)

segments: int, default to 180

Define how much segment is needed for drawing the ellipse. The drawing will be smoother if you have lot of segment.

loop: bool, default to False

Set the bezier curve to join last point to first.

dash_length: int

length of a segment (if dashed), default 1

dash_offset: int

distance between the end of a segment and the start of the next one, default 0, changing this makes it dashed.

dash_length

Property for getting/stting the length of the dashes in the curve

dash_offset

Property for getting/setting the offset between the dashes in the curve

points

Property for getting/settings points of the triangle

Warning

This will always reconstruct the whole graphics from the new points list. It can be very CPU expensive.

segments

Property for getting/setting the number of segments of the curve