vivid v0.1.1 Vivid.Path

Describes a path as a series of vertices.

Summary

Functions

Remove a vertex from a Path

Remove a vertex at a specific index in the Path

Remove a vertex at a specific index in the Path

Initialize a path either empty or from a list of points

Remove a vertex at a specific index in the Path

Remove a vertex at a specific index in the Path

Remove a vertex at a specific index in the Path

Convert a path into a list of lines joined by the vertices

Functions

delete(path, point)

Remove a vertex from a Path.

Example

iex> Vivid.Path.init([Vivid.Point.init(1,1), Vivid.Point.init(2,2)]) |> Vivid.Path.delete(Vivid.Point.init(2,2))
%Vivid.Path{vertices: [%Vivid.Point{x: 1, y: 1}]}
delete_at(path, index)

Remove a vertex at a specific index in the Path.

Example

iex> Vivid.Path.init([Vivid.Point.init(1,1), Vivid.Point.init(2,2)]) |> Vivid.Path.delete_at(1)
%Vivid.Path{vertices: [%Vivid.Point{x: 1, y: 1}]}
first(path)

Remove a vertex at a specific index in the Path.

Example

iex> Vivid.Path.init([Vivid.Point.init(1,1), Vivid.Point.init(2,2)]) |> Vivid.Path.first
%Vivid.Point{x: 1, y: 1}
init()
init(points)

Initialize a path either empty or from a list of points.

Examples

iex> Vivid.Path.init([Vivid.Point.init(1,1), Vivid.Point.init(1,2), Vivid.Point.init(2,2), Vivid.Point.init(2,1)])
%Vivid.Path{vertices: [
  %Vivid.Point{x: 1, y: 1},
  %Vivid.Point{x: 1, y: 2},
  %Vivid.Point{x: 2, y: 2},
  %Vivid.Point{x: 2, y: 1}
]}

iex> Vivid.Path.init
%Vivid.Path{vertices: []}
insert_at(path, index, point)

Remove a vertex at a specific index in the Path.

Example

iex> Vivid.Path.init([Vivid.Point.init(1,1), Vivid.Point.init(2,2)]) |> Vivid.Path.insert_at(1, Vivid.Point.init(3,3))
%Vivid.Path{vertices: [
  %Vivid.Point{x: 1, y: 1},
  %Vivid.Point{x: 3, y: 3},
  %Vivid.Point{x: 2, y: 2}
]}
last(path)

Remove a vertex at a specific index in the Path.

Example

iex> Vivid.Path.init([Vivid.Point.init(1,1), Vivid.Point.init(2,2)]) |> Vivid.Path.last
%Vivid.Point{x: 2, y: 2}
points_to_lines(lines, arg2)
replace_at(path, index, point)

Remove a vertex at a specific index in the Path.

Example

iex> Vivid.Path.init([Vivid.Point.init(1,1), Vivid.Point.init(2,2), Vivid.Point.init(3,3)]) |> Vivid.Path.replace_at(1, Vivid.Point.init(4,4))
%Vivid.Path{vertices: [
  %Vivid.Point{x: 1, y: 1},
  %Vivid.Point{x: 4, y: 4},
  %Vivid.Point{x: 3, y: 3}
]}
to_lines(path)

Convert a path into a list of lines joined by the vertices.

Examples

iex> Vivid.Path.init([Vivid.Point.init(1,1), Vivid.Point.init(1,2), Vivid.Point.init(2,2), Vivid.Point.init(2,1)]) |> Vivid.Path.to_lines
[%Vivid.Line{origin: %Vivid.Point{x: 1, y: 1},
   termination: %Vivid.Point{x: 1, y: 2}},
 %Vivid.Line{origin: %Vivid.Point{x: 1, y: 2},
   termination: %Vivid.Point{x: 2, y: 2}},
 %Vivid.Line{origin: %Vivid.Point{x: 2, y: 2},
   termination: %Vivid.Point{x: 2, y: 1}}]