vivid v0.4.2 Vivid.Group View Source

Represents a collection of shapes which can be Rasterized in a single pass.

Group implements both the Enumerable and Collectable protocols.

Example

iex> use Vivid …> circle = Circle.init(Point.init(10, 10), 10) …> line = Line.init(Point.init(0,0), Point.init(20,20)) …> Group.init([circle, line]) …> |> to_string() “@@@@@@@@@@@@@@@@@@@@@@@\n” <> “@@@@@@@@ @@@@@@ @\n” <> “@@@@@@ @@@@@@@ @@@ @@\n” <> “@@@@@ @@@@@@@@@@@ @ @@@\n” <> “@@@@ @@@@@@@@@@@@@ @@@@\n” <> “@@@ @@@@@@@@@@@@@ @ @@@\n” <> “@@ @@@@@@@@@@@@@ @@@ @@\n” <> “@@ @@@@@@@@@@@@ @@@@ @@\n” <> “@ @@@@@@@@@@@@ @@@@@@ @\n” <> “@ @@@@@@@@@@@ @@@@@@@ @\n” <> “@ @@@@@@@@@@ @@@@@@@@ @\n” <> “@ @@@@@@@@@ @@@@@@@@@ @\n” <> “@ @@@@@@@@ @@@@@@@@@@ @\n” <> “@ @@@@@@@ @@@@@@@@@@@ @\n” <> “@ @@@@@@ @@@@@@@@@@@@ @\n” <> “@@ @@@@ @@@@@@@@@@@@ @@\n” <> “@@ @@@ @@@@@@@@@@@@@ @@\n” <> “@@@ @ @@@@@@@@@@@@@ @@@\n” <> “@@@@ @@@@@@@@@@@@@ @@@@\n” <> “@@@ @ @@@@@@@@@@@ @@@@@\n” <> “@@ @@@ @@@@@@@ @@@@@@\n” <> “@ @@@@@@ @@@@@@@@\n” <> “@@@@@@@@@@@@@@@@@@@@@@@\n”

Link to this section Summary

Functions

Remove a shape from a Group

Initialize an empty group

Initialize a group from a list of shapes

Add a shape to a Group

Link to this section Types

Link to this section Functions

Remove a shape from a Group

Example

iex> line = Vivid.Line.init(Vivid.Point.init(1,1), Vivid.Point.init(10,10))
...> Vivid.Group.init([line])
...> |> Vivid.Group.delete(line)
%Vivid.Group{shapes: MapSet.new()}

Initialize an empty group.

Examples

iex> Vivid.Group.init
#Vivid.Group<[]>

Initialize a group from a list of shapes.

Example

iex> circle = Vivid.Circle.init(Vivid.Point.init(5,5), 5)
...> line   = Vivid.Line.init(Vivid.Point.init(1,1), Vivid.Point.init(10,10))
...> Vivid.Group.init([circle, line])
#Vivid.Group<[#Vivid.Line<[origin: #Vivid.Point<{1, 1}>, termination: #Vivid.Point<{10, 10}>]>, #Vivid.Circle<[center: #Vivid.Point<{5, 5}>, radius: 5]>]>

Add a shape to a Group

Example

iex> line = Vivid.Line.init(Vivid.Point.init(1,1), Vivid.Point.init(10,10))
...> Vivid.Group.init()
...> |> Vivid.Group.put(line)
%Vivid.Group{shapes: MapSet.new([
  %Vivid.Line{origin: %Vivid.Point{x: 1, y: 1}, termination: %Vivid.Point{x: 10, y: 10}}
])}