Skip to content

Paths

Paths

Paths(
    positions: Transform | Buffer,
    indices: Transform | Buffer | list | int,
    line_colors: Transform | Buffer | Color,
    line_widths: Transform | Buffer | float,
    line_styles: Transform | Buffer | LineStyle,
    line_joins: Transform | Buffer | LineJoin,
    line_caps: Transform | Buffer | LineCap,
)

Paths is a set of contiguous lines passing through a series of positions (path). Each path can be colored and styled and possess a thickness. Paths always face the viewer such that their apparent thickness is constant. Their end points (caps) can be styled following the SVG specification (butt, round or cap). Their joins can be styled following partially the SVG specification (round, miter or bevel). The number of paths inside a Paths visual is dictated by the indices variables (see below).

Elements

The number of elements (paths) composing a visual is fully specified by the indices and positions parameters. Considering a positions paramters with n position, indices can be:

  • int (equal to p)
This indicates paths are composed of p consecutives positions. this require p to be a divider of n. The total number of paths N is equal to n/p.
  • Buffer or list of N integers
Each item of the list describes a path made of the given number of consecutive positions. This require the sum of the list to be less or equal to n. The total number of paths is the length of the list N.
  • `list of list or Buffer (of integers)
Each item of the list describe a path made of indexed positions. The total number of paths is the length of the list N. When a buffer is used in place of a list, each item must be separated by the value -1 indicating the end of a path.

Example

Paths([a,b,c,d], 2)                # results in two paths: (a,b) and (c,d)
Paths([a,b,c,d], [2,2])            # results in two paths: (a,b) and (c,d)
Paths([a,b,c,d], [[0,1], [2,3]])   # results in two paths: (a,b) and (c,d)
Paths([a,b,c,d], [0,1,-1, 2,3,-1]) # results in two paths: (a,b) and (c,d)

Attributes

Each attribute of the visual can be assigned per visual (all paths), per path, per position or per vertex, depending on the nature of the attribute and the possible limitations of the server. Let's consider a set of n positions that results in P paths producing N vertices.

Attribute Type per visual (1) per path (P) per positions (n) per vertex (N)
line_colors vec4 ✓︎︎
line_widths float ✓︎︎
line_styles int - -
line_joins int ✓︎︎ - -
line_caps ivec2 - -

Output variables

During rendering, a number of variables are produced and can be referred to in the definition of attributes using the Out transform using their name. The size of these variables are dependents on their nature. Let's consider a set of n positions that results in P paths producing N vertices.

Variable name (string) Type Size Comment
positions/2D vec2 n Positions coordinates (screen)
vertex/positions/2D vec2 N Path vertex coordinates (screen)
vertex/positions/3D vec3 N Path vertex coordinates (space)
vertex/curvilinear/2D float N Curvilinear coordinates along path (2d space)
vertex/curvilinear/3D float N Curvilinear coordinates along path (3d space)

After rendering, once every transforms has been evaluated, a number of variables are readable by other visuals:

Variable name (string) Type Size Comment
vertex/colors vec4 N Line color
vertex/widths float N Line width
path/caps ivec2 P Line caps
path/joins int P Line joins
path/style int P Line style
python docs/snippets/Paths_init.py

Parameters:

Name Type Description Default
positions Transform | Buffer

Paths positions (vec3)

required
indices Transform | List | int

Position indices composing paths (int)

required
line_caps Transform | Buffer | LineCap

Paths end caps (int)

required
line_colors Transform | Buffer | Color

Paths line colors (vec4)

required
line_widths Transform | Buffer | Measure

Paths line width (float)

required

render

render(
    viewport: Viewport,
    model: Matrix = None,
    view: Matrix = None,
    proj: Matrix = None,
)

Render the visual on viewport using the given model, view, proj matrices

Parameters:

Name Type Description Default
viewport Viewport

Viewport where to render the visual

required
model Matrix

Model matrix to use for rendering

None
view Matrix

View matrix to use for rendering

None
proj Matrix

Projection matrix to use for rendering

None