vivid v0.4.1 Vivid.Circle
Represents a circle based on it’s center point and radius.
Summary
Functions
Returns the center point of a circle
Returns the circumference of a circle
Creates a circle from a point in 2D space and a radius
Returns the radius of a circle
Convert the circle
into a Polygon
Convert the circle
into a Polygon with a specific number of vertices
Types
Functions
Returns the center point of a circle.
Example
iex> Vivid.Circle.init(Vivid.Point.init(5,5), 4)
...> |> Vivid.Circle.center
%Vivid.Point{x: 5, y: 5}
Returns the circumference of a circle.
Example
iex> Vivid.Circle.init(Vivid.Point.init(5,5), 4)
...> |> Vivid.Circle.circumference
25.132741228718345
Creates a circle from a point in 2D space and a radius.
Example
iex> Vivid.Circle.init(Vivid.Point.init(5,5), 4)
#Vivid.Circle<[center: #Vivid.Point<{5, 5}>, radius: 4]>
Returns the radius of a circle.
Example
iex> Vivid.Circle.init(Vivid.Point.init(5,5), 4)
...> |> Vivid.Circle.radius
4
Convert the circle
into a Polygon.
We convert a circle into a Polygon whenever we Transform or render it, so sometimes it might be worth doing it yourself and specifying how many vertices the polygon should have.
When unspecified steps
is set to the diameter of the circle rounded to
the nearest integer.
Examples
iex> use Vivid
...> Circle.init(Point.init(5,5), 5)
...> |> Circle.to_polygon
...> |> to_string
"@@@@@@@@@@@@@\n" <>
"@@@@ @@@@\n" <>
"@@@ @@@@@ @@@\n" <>
"@@ @@@@@@@ @@\n" <>
"@@ @@@@@@@ @@\n" <>
"@ @@@@@@@@@ @\n" <>
"@ @@@@@@@@@ @\n" <>
"@ @@@@@@@@@ @\n" <>
"@@ @@@@@@@ @@\n" <>
"@@ @@@@@@@ @@\n" <>
"@@@ @@@@@ @@@\n" <>
"@@@@ @@@@\n" <>
"@@@@@@@@@@@@@\n"
Convert the circle
into a Polygon with a specific number of vertices.
We convert a circle into a Polygon whenever we Transform or render it, so sometimes it might be worth doing it yourself and specifying how many vertices the polygon should have.
Examples
iex> use Vivid
...> Circle.init(Point.init(5,5), 5)
...> |> Circle.to_polygon(3)
...> |> to_string
"@@@@@@@@@@@\n" <>
"@ @@@@@@@@\n" <>
"@ @ @@@@@@\n" <>
"@ @@@ @@@@\n" <>
"@ @@@@@ @@\n" <>
"@ @@@@@@@ @\n" <>
"@ @@@@@ @@\n" <>
"@ @@@ @@@@\n" <>
"@ @@ @@@@@@\n" <>
"@ @@@@@@@\n" <>
"@ @@@@@@@@@\n" <>
"@@@@@@@@@@@\n"