Scenic.Primitives.line

You're seeing just the function line, go back to Scenic.Primitives module for more information.
Link to this function

line(graph_or_primitive, line, opts \\ [])

View Source

Specs

line(
  source :: Scenic.Graph.t() | Scenic.Primitive.t(),
  line :: Scenic.Math.line(),
  options :: list()
) :: Scenic.Graph.t() | Scenic.Primitive.t()

Add a line to a graph.

Lines are pretty simple. They start at one point and go to another.

Data:

{ {from_x, from_y}, {to_x,to_y} }

The following example will draw a diagonal line from the upper left corner {0,0} to the point {100,200}, which is down and to the right.

graph
|> line( {{0,0}, {100,200}} )

Styles

Lines honor the following styles

  • :hidden - If true, the line is skipped. If false, the line is rendered. Default: false.
  • :stroke - The width and paint to draw the line with. If the stroke is not specified, the default stroke is {1, :white}.
  • :cap - Specifies the shape of the ends of the line. Can be one of :round, :butt, or :square. If cap is not specified, then the default is :butt.

Example:

graph
|> line( {{0,0}, {100,200}}, stroke: {4, :blue}, cap: :round )