Draw: primitive drawing

Draw: primitive drawing

pymt.graphx.draw.drawLabel(label, pos=(0, 0), **kwargs)

Draw a label on the window.

Parameters :
label: str

Text to be draw

pos: tuple, default to (0, 0)

Position of text

font_size: int, default to 12

Font size of label

center: bool, default to True

Indicate if pos is center or left-right of label

If you want to get the label object, use getLastLabel() just after your drawLabel().

pymt.graphx.draw.drawRoundedRectangle(pos=(0, 0), size=(100, 50), radius=5, color=None, linewidth=0, precision=0.5, style=GL_POLYGON, corners=(True, True, True, True))

Draw a rounded rectangle

Parameters :
pos: tuple, default to (0, 0)

Position of rectangle

size: tuple, default to (100, 50)

Size of rectangle

radius: int, default to 5

Radius of corner

color: tuple, default to None

Color to be passed to set_color()

linewidth: float (default to current linewidth)

Line with of border

precision: float, default to 0.5

Precision of corner angle

style: opengl begin, default to GL_POLYGON

Style of the rounded rectangle (try GL_LINE_LOOP)

corners: tuple of bool, default to (True, True, True, True)

Indicate if round must be draw for each corners starting to bottom-left, bottom-right, top-right, top-left

pymt.graphx.draw.drawCircle(pos=(0, 0), radius=1.0, linewidth=0)

Draw a simple circle

Parameters :
pos: tuple, default to (0, 0)

Position of circle

radius: float, default to 1.0

Radius of circle

pymt.graphx.draw.drawPolygon(points, style=GL_POLYGON, linewidth=0)

Draw polygon from points list

Parameters :
points: list

List of points, length must be power of 2. (x,y,x,y...)

style: opengl begin, default to GL_POLYGON

Default type to draw (will be passed to glBegin) can also be string

'fill' == 'GL_POLYGON' == GL_POLYGON
'line' == 'GL_LINE_LOOP' == GL_LINE_LOOP
linewidth: int, defaults to current OpenGL state.

Sets the linewidth if drawign style is a line based one

pymt.graphx.draw.drawTriangle(pos, w, h, style=GL_POLYGON, linewidth=0)

Draw one triangle

Parameters :
pos: tuple

Position of triangle

w: int

Width of triangle

h: int

Height of triangle

style: opengl begin, default to GL_POLYGON

Default type to draw (will be passed to glBegin) can also be string

'fill' == 'GL_POLYGON' == GL_POLYGON
'line' == 'GL_LINE_LOOP' == GL_LINE_LOOP
linewidth: int, defaults to current OpenGL state.

Sets the linewidth if drawign style is a line based one

pymt.graphx.draw.drawRectangle(pos=(0, 0), size=(1.0, 1.0), style=GL_QUADS)

Draw a simple rectangle

Parameters :
pos: tuple, default to (0, 0)

Position of rectangle

size: tuple, default to (1.0, 1.0)

Size of rectangle

style: opengl begin, default to GL_QUADS

Style of rectangle (try GL_LINE_LOOP)

pymt.graphx.draw.drawTexturedRectangle(texture, pos=(0, 0), size=(1.0, 1.0), tex_coords=None, color_coords=None)

Draw a rectangle with a texture. The rectangle is drawed from bottom-left, bottom-right, top-right, top-left.

Parameters :
texture: Texture

Texture object, created with Texture().

pos: tuple, default to (0, 0)

Position of rectangle

size: tuple, default to (1.0, 1.0)

Size of rectangle

tex_coords: list, default to None

Contain a list of UV coords to use. If None, texture UV coordinates will be used.

color_coords: list, default to None

Specify a color for each vertex. The format is 4 colors tuples in a list.

pymt.graphx.draw.drawLine(points, width=None, colors=[])

Draw a line

Parameters :
points: list

List of corresponding coordinates representing the points that the line comprises, like [x1, y1, x2, y2]. Hence, len(points) must be a power of 2.

width: float, defaults to 5.0

Default width of line

colors: list of tuples, defaults to []

If you want to draw colors between the points of the line (with blending), this list has to be populated with r,g,b values for each point. E.g.: drawLine([0, 0, 200, 200], colors=[1., 0, 0, 0, 1., 0]) Turned off by default.

pymt.graphx.draw.drawRectangleAlpha(pos=(0, 0), size=(1.0, 1.0), alpha=(1, 1, 1, 1), style=GL_QUADS)

Draw an rectangle alpha layer.

Parameters :
pos: tuple, default to (0, 0)

Position of rectangle

size: tuple, default to (1.0, 1.0)

Size of rectangle

alpha: list, default to (1, 1, 1, 1)

Alpha to set in each corner (top, right, bottom, left)

style: opengl begin, default to GL_QUADS

Style of rectangle (try GL_LINE_LOOP)

pymt.graphx.draw.drawRoundedRectangleAlpha(pos=(0, 0), size=(100, 50), radius=5, alpha=(1, 1, 1, 1), precision=0.5, style=GL_TRIANGLE_FAN)

Draw a rounded rectangle alpha layer.

Parameters :
pos: tuple, default to (0, 0)

Position of rectangle

size: tuple, default to (100, 50)

Size of rectangle

radius: int, default to 5

Radius of corner

alpha: list, default to (1, 1, 1, 1)

Alpha to set in each corner (top, right, bottom, left)

precision: float, default to 0.5

Precision of corner angle

style: opengl begin, default to GL_POLYGON

Style of the rounded rectangle (try GL_LINE_LOOP)

pymt.graphx.draw.drawSemiCircle(pos=(0, 0), inner_radius=100, outer_radius=120, slices=32, loops=1, start_angle=0, sweep_angle=360)

Draw a semi-circle. You can choose the start angle, and the ending angle (from 0 to 360), and the inner/outer radius !

Parameters :
pos: tuple, default to (0, 0)

Center position of the circle

inner_radius: int, default to 100

Radius of the inner circle

outer_radius: int, default to 120

Radius of the outer circle

slices: int, default to 32

Precision of circle drawing

start_angle: int, default to 0

Angle to start drawing

sweep_angle: int, default to 360

Angle to finish drawing

pymt.graphx.draw.drawStippledCircle(pos=(0, 0), inner_radius=200, outer_radius=400, segments=10)

Draw a stippled circle. A stippled circle consists of several equally-sized segments, with a gap between every two segments. The gap is the size of a segment. The circle’s position and thickness can be specified.

Parameters :
pos: tuple, default to (0, 0)

Center position of the circle

inner_radius: int, default to 100

Radius of the inner circle

outer_radius: int, default to 120

Radius of the outer circle

segments: int, defaults to 10

Number of visible segments

pymt.graphx.draw.getLabel(label, **kwargs)

Get a cached label object

Parameters :
label: str

Text to be draw

font_size: int, default to 12

Font size of label

center: bool, default to True

Indicate if pos is center or left-right of label

getLabel() support all parameters from the Core label. Check LabelBase class to known all availables parameters.

Used by drawLabel()

Previous topic

CSS: Draw shapes with css attributes !

Next topic

Fbo: abstraction to use hardware/software FrameBuffer object

This Page