vispy.visuals.scrolling_lines module

class vispy.visuals.scrolling_lines.ScrollingLinesVisual(n_lines, line_size, dx, color=None, pos_offset=None, columns=None, cell_size=None)[source]

Bases: vispy.visuals.visual.Visual

Displays many line strips of equal length, with the option to add new vertex data to one end of the lines.

Parameters
n_linesint

The number of independent line strips to draw.

line_sizeint

The number of samples in each line strip.

dxfloat

The x distance between samples

colorarray-like

An array of colors to assign to each line strip.

pos_offsetarray-like

An array of x, y position offsets to apply to each line strip.

columnsint

Arrange line strips into a grid with this number of columns. This option is not compatible with pos_offset.

cell_sizetuple

The x, y distance between cells in the grid.

fragment_code = '\n varying vec2 v_index;\n varying vec4 v_color;\n \n void main() {\n if (v_index.y - floor(v_index.y) > 0) {\n discard;\n }\n gl_FragColor = $color;\n }\n '
roll_data(data)[source]

Append new data to the right side of every line strip and remove as much data from the left.

Parameters
dataarray-like

A data array to append.

set_color(color)[source]

Set the array of colors for each line strip.

Parameters
colorarray-like

An array of rgba values.

set_data(index, data)[source]

Set the complete data for a single line strip.

Parameters
indexint

The index of the line strip to be replaced.

dataarray-like

The data to assign to the selected line strip.

set_pos_offset(po)[source]

Set the array of position offsets for each line strip.

Parameters
poarray-like

An array of xy offset values.

vertex_code = '\n attribute vec2 index; // .x=line_n, .y=vertex_n\n uniform sampler2D position;\n uniform sampler1D pos_offset;\n uniform sampler1D color_tex;\n \n uniform vec2 pos_size; // x=n_lines, y=n_verts_per_line\n uniform float offset; // rolling pointer into vertexes\n uniform float dx; // x step per sample\n \n varying vec2 v_index;\n varying vec4 v_color;\n \n \n void main() {\n v_index = vec2(mod(index.y + offset, pos_size.y), index.x);\n vec2 uv = (v_index + 0.5) / (pos_size.yx);\n vec4 pos = vec4(index.y * dx, texture2D(position, uv).r, 0, 1);\n \n // fetch starting position from texture lookup:\n pos += vec4(texture1D(pos_offset, (index.x + 0.5) / pos_size.x).rg,\n 0, 0); \n \n gl_Position = $transform(pos);\n \n v_color = texture1D(color_tex, (index.x + 0.5) / pos_size.x);\n }\n '