17. decors — 2D decorations for the OpenGL canvas.

2D decorations for the OpenGL canvas.

class decors.Decoration(x, y)

A decoration is a 2-D drawing at canvas position x,y.

All decoration have at least the following attributes:

x,y : (int) window coordinates of the insertion point drawGL() : function that draws the decoration at (x,y).

This should only use openGL function that are allowed in a display list.

Methods

Create a decoration at canvas coordinates x,y

Methods

Decoration objects have the following methods:

class decors.Mark(x, y, mark='dot', color=None, linewidth=None)

A mark at a fixed position on the canvas.

Methods

Mark objects have the following methods:

drawGL(mode='wireframe', color=None)
class decors.Line(x1, y1, x2, y2, color=None, linewidth=None)

A straight line on the canvas.

Methods

Line objects have the following methods:

drawGL(mode='wireframe', color=None)
class decors.GlutText(text, x, y, font='9x15', size=None, gravity=None, color=None, zoom=None)

A viewport decoration showing a text string.

  • text: a simple string, a multiline string or a list of strings. If it is a string, it will be splitted on the occurrence of ‘
‘ characters.
  • x,y: insertion position on the canvas
  • gravity: a string that determines the adjusting of the text with respect to the insert position. It can be a combination of one of the characters ‘N or ‘S’ to specify the vertical positon, and ‘W’ or ‘E’ for the horizontal. The default(empty) string will center the text.

Methods

Create a text actor

Methods

GlutText objects have the following methods:

drawGL(mode='wireframe', color=None)
Draw the text.
class decors.ColorLegend(colorlegend, x, y, w, h, font=None, size=None, dec=2, scale=0, grid=0, linewidth=None, lefttext=False, nlabels=-1)

A viewport decoration showing a colorscale legend.

Methods

ColorLegend objects have the following methods:

drawGL(mode='wireframe', color=None)
use_list()
class decors.Rectangle(x1, y1, x2, y2, color=None)

A 2D-rectangle on the canvas.

Methods

Rectangle objects have the following methods:

drawGL(mode='wireframe', color=None)
class decors.Grid(x1, y1, x2, y2, nx=1, ny=1, color=None, linewidth=None)

A 2D-grid on the canvas.

Methods

Grid objects have the following methods:

drawGL(mode='wireframe', color=None)
class decors.LineDrawing(data, color=None, linewidth=None)

A collection of straight lines on the canvas.

Methods

Initially a Line Drawing.

data can be a 2-plex Formex or equivalent coordinate data. The z-coordinates of the Formex are unused. A (n,2,2) shaped array will do as well.

Methods

LineDrawing objects have the following methods:

drawGL(mode=None, color=None)
class decors.Triade(pos='lb', siz=100, pat='12-34', legend='xyz', color=[, (1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0), (0.0, 1.0, 1.0), (1.0, 0.0, 1.0), (1.0, 1.0, 0.0)])

An OpenGL actor representing a triade of global axes.

  • pos: position on the canvas: two charaters, of which first sets

    horizontal position (‘l’, ‘c’ or ‘r’) and second sets vertical position (‘b’, ‘c’ or ‘t’).

  • size: size in pixels of the zone displaying the triade.

  • pat: shape to be drawn in the coordinate planes. Default is a square. ‘16’ givec a triangle. ‘’ disables the planes.

  • legend: text symbols to plot at the end of the axes. A 3-character string or a tuple of 3 strings.

Methods

Triade objects have the following methods:

draw(mode='wireframe', color=None)

Functions defined in the module decors

decors.drawDot(x, y)
Draw a dot at canvas coordinates (x,y).
decors.drawLine(x1, y1, x2, y2)
Draw a straight line from (x1,y1) to (x2,y2) in canvas coordinates.
decors.drawGrid(x1, y1, x2, y2, nx, ny)

Draw a rectangular grid of lines

The rectangle has (x1,y1) and and (x2,y2) as opposite corners. There are (nx,ny) subdivisions along the (x,y)-axis. So the grid has (nx+1) * (ny+1) lines. nx=ny=1 draws a rectangle. nx=0 draws 1 vertical line (at x1). nx=-1 draws no vertical lines. ny=0 draws 1 horizontal line (at y1). ny=-1 draws no horizontal lines.

decors.drawRect(x1, y1, x2, y2)
decors.drawRectangle(x1, y1, x2, y2, color)

Documentation

Previous topic

16. actors — OpenGL actors for populating the 3D scene.

Next topic

18. marks — OpenGL marks for annotating 3D actors.

This Page