View Source Scenic.Primitive.Line (Scenic v0.12.0-rc.0)

Draw a line on the screen.

Data

{point_a, point_b}

The data for a line is a tuple containing two points.

  • point_a - position to start drawing from
  • point_b - position to draw to

Styles

This primitive recognizes the following styles

  • hidden - show or hide the primitive
  • scissor - "scissor rectangle" that drawing will be clipped to.
  • cap - says how to draw the ends of the line.
  • stroke - stroke the outline of the primitive. In this case, only the curvy part.

Usage

You should add/modify primitives via the helper functions in Scenic.Primitives

graph
  |> line( {{0, 0}, {20, 40}}, stroke: {1, :yellow} )

Summary

Functions

Returns the midpoint of the line. This is used as the default pin when applying rotate or scale transforms.

Compile the data for this primitive into a mini script. This can be combined with others to generate a larger script and is called when a graph is compiled.

Returns a list of styles recognized by this primitive.

Types

@type styles_t() :: [:hidden | :scissor | :stroke_width | :stroke_fill | :cap]
@type t() :: {{x0 :: number(), y0 :: number()}, {x1 :: number(), y1 :: number()}}

Functions

Link to this function

bounds(data, mx, styles)

View Source

Returns the midpoint of the line. This is used as the default pin when applying rotate or scale transforms.

Link to this function

compile(primitive, arg2)

View Source
@spec compile(primitive :: Scenic.Primitive.t(), styles :: Scenic.Primitive.Style.t()) ::
  Scenic.Script.t()

Compile the data for this primitive into a mini script. This can be combined with others to generate a larger script and is called when a graph is compiled.

Link to this function

default_pin(data, styles)

View Source
@spec valid_styles() :: styles_t()

Returns a list of styles recognized by this primitive.