View Source Vivid.Group (vivid v0.4.4)
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"
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
Types
@type t() :: %Vivid.Group{shapes: MapSet.t(Vivid.Shape.t())}
Functions
@spec delete(t(), Vivid.Shape.t()) :: t()
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()}
@spec init() :: t()
Initialize an empty group.
Examples
iex> Vivid.Group.init
%Vivid.Group{shapes: MapSet.new([])}
@spec init(Enumerable.t(Vivid.Shape.t())) :: t()
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.init([Vivid.Line.init(Vivid.Point.init(1, 1), Vivid.Point.init(10, 10)), Vivid.Circle.init(Vivid.Point.init(5, 5), 5)])
@spec put(t(), Vivid.Shape.t()) :: t()
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}}
])}