LineStrips2D

2D line strips with positions and optional colors, radii, labels, etc.

Components components

Required: LineStrip2D

Recommended: Radius, Color

Optional: Text, DrawOrder, ClassId

Shown in shown-in

Examples examples

line_strip2d_simple linestrip2dsimple

"""Log a simple line strip."""

import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_line_strip2d", spawn=True)

rr.log(
    "strip",
    rr.LineStrips2D([[[0, 0], [2, 1], [4, -1], [6, 0]]]),
)

# Set view bounds:
rr.send_blueprint(rrb.Spatial2DView(visual_bounds=rrb.VisualBounds2D(x_range=[-1, 7], y_range=[-3, 3])))

line_segments2d_simple linesegments2dsimple

"""Log a couple 2D line segments using 2D line strips."""

import numpy as np
import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_line_segments2d", spawn=True)

rr.log(
    "segments",
    rr.LineStrips2D(np.array([[[0, 0], [2, 1]], [[4, -1], [6, 0]]])),
)

# Set view bounds:
rr.send_blueprint(rrb.Spatial2DView(visual_bounds=rrb.VisualBounds2D(x_range=[-1, 7], y_range=[-3, 3])))

line_strip2d_batch linestrip2dbatch

"""Log a batch of 2D line strips."""

import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_line_strip2d_batch", spawn=True)

rr.log(
    "strips",
    rr.LineStrips2D(
        [
            [[0, 0], [2, 1], [4, -1], [6, 0]],
            [[0, 3], [1, 4], [2, 2], [3, 4], [4, 2], [5, 4], [6, 3]],
        ],
        colors=[[255, 0, 0], [0, 255, 0]],
        radii=[0.025, 0.005],
        labels=["one strip here", "and one strip there"],
    ),
)

# Set view bounds:
rr.send_blueprint(rrb.Spatial2DView(visual_bounds=rrb.VisualBounds2D(x_range=[-1, 7], y_range=[-3, 6])))

Lines with scene & UI radius each lines-with-scene--ui-radius-each

"""Log lines with ui points & scene unit radii."""

import rerun as rr

rr.init("rerun_example_line_strip3d_ui_radius", spawn=True)

# A blue line with a scene unit radii of 0.01.
points = [[0, 0, 0], [0, 0, 1], [1, 0, 0], [1, 0, 1]]
rr.log(
    "scene_unit_line",
    rr.LineStrips3D(
        [points],
        # By default, radii are interpreted as world-space units.
        radii=0.01,
        colors=[0, 0, 255],
    ),
)

# A red line with a ui point radii of 5.
# UI points are independent of zooming in Views, but are sensitive to the application UI scaling.
# For 100% ui scaling, UI points are equal to pixels.
points = [[3, 0, 0], [3, 0, 1], [4, 0, 0], [4, 0, 1]]
rr.log(
    "ui_points_line",
    rr.LineStrips3D(
        [points],
        # rr.Radius.ui_points produces radii that the viewer interprets as given in ui points.
        radii=rr.Radius.ui_points(5.0),
        colors=[255, 0, 0],
    ),
)