A special line visual which can also draw optional arrow heads at the
specified vertices.

You add an arrow head by specifying two vertices v1 and v2 which
represent the arrow body. This visual will draw an arrow head using v2
as center point, and the orientation of the arrow head is automatically
determined by calculating the direction vector between v1 and v2.

Parameters:

pos : array

Array of shape (…, 2) or (…, 3) specifying vertex coordinates.

color : Color, tuple, or array

The color to use when drawing the line. If an array is given, it
must be of shape (…, 4) and provide one rgba color per vertex.
Can also be a colormap name, or appropriate Function.

width:

The width of the line in px. Line widths > 1px are only
guaranteed to work when using ‘agg’ method.

connect : str or array

Determines which vertices are connected by lines.

“strip” causes the line to be drawn with each vertex
connected to the next.

“segments” causes each pair of vertices to draw an
independent line segment

“gl” uses OpenGL’s built-in line rendering. This is much faster,
but produces much lower-quality results and is not guaranteed to
obey the requested line width or join/endcap styles.

antialias : bool

Enables or disables antialiasing.
For method=’gl’, this specifies whether to use GL’s line smoothing,
which may be unavailable or inconsistent on some platforms.

arrows : array

A (N, 4) or (N, 6) matrix where each row contains the (x, y) or the
(x, y, z) coordinate of the first and second vertex of the arrow
body. Remember that the second vertex is used as center point for
the arrow head, and the first vertex is only used for determining
the arrow head orientation.

arrow_type : string

Specify the arrow head type, the currently available arrow head types
are:

stealth

curved

triangle_30

triangle_60

triangle_90

angle_30

angle_60

angle_90

inhibitor_round

arrow_size : float

Specify the arrow size

arrow_color : Color, tuple, or array

The arrow head color. If an array is given, it must be of shape
(…, 4) and provide one rgba color per arrow head. Can also be a
colormap name, or appropriate Function.

The color to use when drawing the line. If an array is given, it
must be of shape (…, 4) and provide one rgba color per vertex.
Can also be a colormap name, or appropriate Function.

width:

The width of the line in px. Line widths > 1px are only
guaranteed to work when using ‘agg’ method.

connect : str or array

Determines which vertices are connected by lines.

“strip” causes the line to be drawn with each vertex
connected to the next.

“segments” causes each pair of vertices to draw an
independent line segment

numpy arrays specify the exact set of segment pairs to
connect.

arrows : array

A (N, 4) or (N, 6) matrix where each row contains the (x, y) or the
(x, y, z) coordinate of the first and second vertex of the arrow
body. Remember that the second vertex is used as center point for
the arrow head, and the first vertex is only used for determining
the arrow head orientation.

The data values at the beginning and end of the axis, used for tick
labels. i.e. (5, 10) means the axis starts at 5 and ends at 10. Default
is (0, 1).

tick_direction : array

The tick direction to use (in document coordinates).

scale_type : str

The type of scale. For now only ‘linear’ is supported.

axis_color : tuple

RGBA values for the axis colour. Default is black.

tick_color : tuple

RGBA values for the tick colours. The colour for the major and minor
ticks is currently fixed to be the same. Default is a dark grey.

text_color : Color

The color to use for drawing tick and axis labels

minor_tick_length : float

The length of minor ticks, in pixels

major_tick_length : float

The length of major ticks, in pixels

tick_width : float

Line width for the ticks

tick_label_margin : float

Margin between ticks and tick labels

tick_font_size : float

The font size to use for rendering tick labels.

axis_width : float

Line width for the axis

axis_label : str

Text to use for the axis label

axis_label_margin : float

Margin between ticks and axis labels

axis_font_size : float

The font size to use for rendering axis labels.

font_size : float

Font size for both the tick and axis labels. If this is set,
tick_font_size and axis_font_size are ignored.

anchors : iterable

A 2-element iterable (tuple, list, etc.) giving the horizontal and
vertical alignment of the tick labels. The first element should be one
of ‘left’, ‘center’, or ‘right’, and the second element should be one
of ‘bottom’, ‘middle’, or ‘top’. If this is not specified, it is
determined automatically.

To the user, a compound visual behaves exactly like a normal visual–it
has a transform system, draw() and bounds() methods, etc. Internally, the
compound visual automatically manages proxying these transforms and methods
to its sub-visuals.

This makes it simple to generate a mesh from e.g. the output
of numpy.meshgrid.

All arguments are optional, though they can be changed
individually later with the set_data method.

Parameters:

xs : ndarray

A 2d array of x coordinates for the vertices of the mesh. Must
have the same dimensions as ys and zs.

ys : ndarray

A 2d array of y coordinates for the vertices of the mesh. Must
have the same dimensions as xs and zs.

zs : ndarray

A 2d array of z coordinates for the vertices of the mesh. Must
have the same dimensions as xs and ys.

colors : ndarray | None

The colors of the points of the mesh. Should be either a
(width, height, 4) array of rgba colors at each grid point or
a (width, height, 3) array of rgb colors at each grid point.
Defaults to None, in which case the default color of a
MeshVisual is used.

Selects method of rendering image in case of non-linear transforms.
Each method produces similar results, but may trade efficiency
and accuracy. If the transform is linear, this parameter is ignored
and a single quad is drawn around the area of the image.

‘auto’: Automatically select ‘impostor’ if the image is drawn
with a nonlinear transform; otherwise select ‘subdivide’.

‘subdivide’: ImageVisual is represented as a grid of triangles
with texture coordinates linearly mapped.

‘impostor’: ImageVisual is represented as a quad covering the
entire view, with texture coordinates determined by the
transform. This produces the best transformation results, but may
be slow.

grid: tuple (rows, cols)

If method=’subdivide’, this tuple determines the number of rows and
columns in the image grid.

cmap : str | ColorMap

Colormap to use for luminance images.

clim : str | tuple

Limits to use for the colormap. Can be ‘auto’ to auto-set bounds to
the min and max of the data.

interpolation : str

Selects method of image interpolation. Makes use of the two Texture2D
interpolation methods and the available interpolation methods defined
in vispy/gloo/glsl/misc/spatial_filters.frag

1D array of values specifying the x positions of vertices in the
grid. If None, values will be assumed to be integers.

y : ndarray | None

1D array of values specifying the x positions of vertices in the
grid. If None, values will be assumed to be integers.

z : ndarray

2D array of height values for each grid vertex.

colors : ndarray

(width, height, 4) array of vertex colors.

Notes

All arguments are optional.

Note that if vertex positions are updated, the normal vectors for each
triangle must be recomputed. This is somewhat expensive if the surface
was initialized with smooth=False and very expensive if smooth=True.
For faster performance, initialize with compute_normals=False and use
per-vertex colors or a material that does not require normals.

The tube mesh is corrected following its Frenet curvature and
torsion such that it varies smoothly along the curve, including if
the tube is closed.

Parameters:

points : ndarray

An array of (x, y, z) points describing the path along which the
tube will be extruded.

radius : float

The radius of the tube. Defaults to 1.0.

closed : bool

Whether the tube should be closed, joining the last point to the
first. Defaults to False.

color : Color | ColorArray

The color(s) to use when drawing the tube. The same color is
applied to each vertex of the mesh surrounding each point of
the line. If the input is a ColorArray, the argument will be
cycled; for instance if ‘red’ is passed then the entire tube
will be red, or if [‘green’, ‘blue’] is passed then the points
will alternate between these colours. Defaults to ‘purple’.

tube_points : int

The number of points in the circle-approximating polygon of the
tube’s cross section. Defaults to 8.

Base class for all visuals that can be drawn using a single shader
program.

This class creates a MultiProgram, which is an object that
behaves like a normal shader program (you can assign shader code, upload
values, set template variables, etc.) but internally manages multiple
ModularProgram instances, one per view.

Subclasses generally only need to reimplement _compute_bounds,
_prepare_draw, and _prepare_transforms.

Parameters:

vcode : str

Vertex shader code.

fcode : str

Fragment shader code.

program : instance of Program | None

The program to use. If None, a program will be constructed using
vcode and fcode.

Larger values yield higher performance at reduced quality. If
set > 2.0 the ray skips entire voxels. Recommended values are
between 0.5 and 1.5. The amount of quality degredation depends
on the render method.

TransformSystem encapsulates information about the coordinate
systems needed to draw a Visual.

Visual rendering operates in six coordinate systems:

Visual - arbitrary local coordinate frame of the visual. Vertex
buffers used by the visual are usually specified in this coordinate
system.

Scene - This is an isometric coordinate system used mainly for
lighting calculations.

Document - This coordinate system has units of _logical_ pixels, and
should usually represent the pixel coordinates of the canvas being drawn
to. Visuals use this coordinate system to make measurements for font
size, line width, and in general anything that is specified in physical
units (px, pt, mm, in, etc.). In most circumstances, this is exactly the
same as the canvas coordinate system.

Canvas - This coordinate system represents the logical pixel
coordinates of the canvas. It has its origin in the top-left corner of
the canvas, and is typically the coordinate system that mouse and touch
events are reported in. Note that, by convention, _logical_ pixels
are not necessarily the same size as the _physical_ pixels in the
framebuffer that is being rendered to.

Framebuffer - The buffer coordinate system has units of _physical_
pixels, and should usually represent the coordinates of the current
framebuffer (on the canvas or an FBO) being rendered to. Visuals use this
coordinate system primarily for antialiasing calculations. It is also the
coorinate system used by glFragCoord. In most cases,
this will have the same scale as the document and canvas coordinate
systems because the active framebuffer is the
back buffer of the canvas, and the canvas will have _logical_ and
_physical_ pixels of the same size. However, the scale may be different
in the case of high-resolution displays, or when rendering to an
off-screen framebuffer with different scaling or boundaries than the
canvas.

Render - This coordinate system is the obligatory system for
vertices returned by a vertex shader. It has coordinates (-1, -1) to
(1, 1) across the current glViewport. In OpenGL terminology, this is
called clip coordinates.

Parameters:

canvas : Canvas

The canvas being drawn to.

dpi : float

The dot-per-inch resolution of the document coordinate system. By
default this is set to the resolution of the canvas.

Notes

By default, TransformSystems are configured such that the document
coordinate system matches the logical pixels of the canvas,

Examples

1. To convert local vertex coordinates to normalized device coordinates in
the vertex shader, we first need a vertex shader that supports configurable
transformations:

In this case, we need to access
the transforms independently, so get_full_transform() is not useful
here:

defdraw(tr_sys):# Send two parts of the full transform separatelyself.program['visual_to_doc']=tr_sys.visual_to_doc.shader_map()doc_to_render=(tr_sys.framebuffer_transform*tr_sys.document_transform)self.program['visual_to_doc']=doc_to_render.shader_map()self.program['u_line_width']=self.line_widthself.program['u_dpi']=tr_sys.dpiself.program['a_position']=self.vertex_bufferself.program['a_normal']=self.normal_bufferself.program.draw('triangles')

canvas_transform maps from the Canvas logical pixel
coordinate system to the framebuffer coordinate system, taking into
account the logical/physical pixel scale factor, current FBO
position, and y-axis inversion.

framebuffer_transform maps from the current GL viewport on the
framebuffer coordinate system to clip coordinates (-1 to 1).

Parameters:

viewport : tuple or None

The GL viewport rectangle (x, y, w, h). If None, then it
is assumed to cover the entire canvas.

fbo_size : tuple or None

The size of the active FBO. If None, then it is assumed to have the
same size as the canvas’s framebuffer.

fbo_rect : tuple or None

The position and size (x, y, w, h) of the FBO in the coordinate
system of the canvas’s framebuffer. If None, then the bounds are
assumed to cover the entire active framebuffer.

canvas : Canvas instance

Optionally set the canvas for this TransformSystem. See the
canvas property.