주요 콘텐츠

drawLines

R2026b

Draw connected line segments in RoadRunner Viewer scene graph

Since R2026b

    Description

    drawLines(pc,points,color,width) draws connected line segments, of the specified width and color, between the consecutive point positions points, using world coordinates, in the specified primitive collection pc in the RoadRunner Viewer scene graph.

    example

    Examples

    collapse all

    Use a PrimitiveCollection object and the drawLines function to draw a green polyline in the RoadRunner Viewer scene graph. This example assumes you have already added the folder containing the RoadRunner API to your MATLAB® path. For information on getting started with RoadRunner Viewer, see Get Started with RoadRunner Viewer (RoadRunner Scenario).

    Open RoadRunner Viewer and create a roadrunnerViewer object rrViewer.

    rrViewer = roadrunnerViewer;

    To create a PrimitiveCollection object, pc, use the addPrimitive function and specify the roadrunnerViewer object rrViewer.

    pc = addPrimitive(rrViewer);

    Draw a green polyline in the RoadRunner Viewer scene graph. Use the drawLines function and specify the primitive collection pc, the polyline point positions linePts, the line color, and the line width.

    linePts = [0 0 1; 1 1 1; 2 0 1; 3 1 1; 4 0 1];
    drawLines(pc,linePts,[0 0.8 0],3);

    To update RoadRunner Viewer and view the changes to the primitives, use the drawnow function.

    drawnow(rrViewer)

    Input Arguments

    collapse all

    Primitive collection in which to add lines, specified as a PrimitiveCollection object.

    Line point positions, in world coordinates, specified as an N-by-3 matrix. N is the number of points, and the columns [x y z] represent the x-, y-, and z-positions of each point, respectively. Because drawLines draws a line between pairs of consecutive points, the function requires at least two point values. If you do not specify at least two point values, drawLines does nothing.

    Line color, specified as a four-element vector of the form [R,G,B,A], a three-element vector of the form [R,G,B], a string scalar, or a character vector. If specified as a vector, R, G, B, and A represent the red, green, blue, and alpha values for the line color, respectively. If specified as a string scalar or character vector, you must use a color name, such as "blue", or a hexadecimal value, such as "#0072BD".

    This table lists the named color options, the equivalent RGBA values, and the hexadecimal color codes.

    Color NameShort NameRGBA ValueHexadecimal Color CodeAppearance
    "red""r"[1 0 0 1]"#FF0000"

    Sample of the color red

    "green""g"[0 1 0 1]"#00FF00"

    Sample of the color green

    "blue""b"[0 0 1 1]"#0000FF"

    Sample of the color blue

    "cyan" "c"[0 1 1 1]"#00FFFF"

    Sample of the color cyan

    "magenta""m"[1 0 1 1]"#FF00FF"

    Sample of the color magenta

    "yellow""y"[1 1 0 1]"#FFFF00"

    Sample of the color yellow

    "black""k"[0 0 0 1]"#000000"

    Sample of the color black

    "white""w"[1 1 1 1]"#FFFFFF"

    Sample of the color white

    Line width, specified as a numeric scalar, in pixels.

    Version History

    Introduced in R2026b