vivid v0.4.2 Vivid.Circle View Source

Represents a circle based on it’s center point and radius.

Example

iex> use Vivid …> Circle.init(Point.init(10,10), 10) …> |> 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

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

Link to this section Types

Link to this section 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}
Link to this function circumference(circle) View Source
circumference(Vivid.Circle.t) :: number

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]>
Link to this function radius(circle) View Source
radius(Cricle.t) :: number

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"
Link to this function to_polygon(circle, steps) View Source
to_polygon(Vivid.Circle.t, number) :: Vivid.Polygon.t

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"