Markex.Element (markex v1.0.0) View Source
Creating and working with elements for 2D markup
Link to this section Summary
Functions
Positions this
to the left of that
, makes the elements higher if needed
The correct way to get the height of an element
Adds space to the top and bottom of the element
so that the height matches n
Creates new element using regular string or list of strings
Fills an element of length w
and height h
with char ch
Positions this
on top of that
, makes the elements wider as needed
The correct and safe way to get the width and height of an element
Return string representation of element
Adds space to the sides of the element
so that the width matches n
The correct and safe way to get the width of an element
Link to this section Types
Specs
element() :: [String.t()]
List of strings, where all string the same length
Link to this section Functions
Specs
Positions this
to the left of that
, makes the elements higher if needed
See also Markex.Element.Operators.<|>/2
and Markex.Element.higher/2
.
Examples
iex> Markex.Element.beside(Markex.Element.new("#"), Markex.Element.new("$", 2, 3))
[
" $$",
"#$$",
" $$"
]
Specs
height(element()) :: non_neg_integer()
The correct way to get the height of an element
Also see Markex.Element.size/1
Specs
higher(element(), pos_integer()) :: element()
Adds space to the top and bottom of the element
so that the height matches n
Examples
iex> Markex.Element.new("#") |> Markex.Element.higher(6)
[
" ",
" ",
"#",
" ",
" ",
" "
]
Specs
Creates new element using regular string or list of strings
In the latter case, automatically makes all strings the same length.
Examples
iex> Markex.Element.new("Hello, world!")
["Hello, wordl!"]
iex> Markex.Element.new(["Hello, world!", "or something idk", "."])
[
"Hello, world! ",
"or something idk",
". "
]
Specs
new(String.t(), non_neg_integer(), non_neg_integer()) :: element()
Fills an element of length w
and height h
with char ch
Examples
iex> Markex.Element.new("#", 5, 5)
[
"#####",
"#####",
"#####",
"#####",
"#####"
]
Specs
Positions this
on top of that
, makes the elements wider as needed
See also Markex.Element.Operators.<~>/2
and Markex.Element.wider/2
.
Examples
iex> Markex.Element.over(Markex.Element.new("#", 1, 2), Markex.Element.new("$", 3, 2))
[
" # ",
" # ",
"$$$",
"$$$"
]
Specs
size(element()) :: {non_neg_integer(), non_neg_integer()}
The correct and safe way to get the width and height of an element
See also Markex.Element.width/1
and Markex.Element.height/1
.
Examples
iex> Markex.Element.new("#", 4, 5) |> Markex.Element.size()
{4, 5}
Specs
Return string representation of element
Examples
iex> Markex.Element.new("#", 2, 2) |> Markex.Element.to_string()
"##\n##"
Specs
wider(element(), pos_integer()) :: element()
Adds space to the sides of the element
so that the width matches n
Examples
iex> Markex.Element.new("#") |> Markex.Element.wider(6)
[
" # "
]
Specs
width(element()) :: non_neg_integer()
The correct and safe way to get the width of an element
Also see Markex.Element.size/1