FTXUI  5.0.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
Canvas Struct Reference

Public Types

using Stylizer = std::function<void(Pixel&)>

Public Member Functions

 Canvas ()=default
 Canvas (int width, int height)
 Constructor.
int width () const
int height () const
Pixel GetPixel (int x, int y) const
 Get the content of a cell.
void DrawPointOn (int x, int y)
 Draw a braille dot.
void DrawPointOff (int x, int y)
 Erase a braille dot.
void DrawPointToggle (int x, int y)
 Toggle a braille dot. A filled one will be erased, and the other will be drawn.
void DrawPoint (int x, int y, bool value)
 Draw a braille dot.
void DrawPoint (int x, int y, bool value, const Stylizer &s)
 Draw a braille dot.
void DrawPoint (int x, int y, bool value, const Color &color)
 Draw a braille dot.
void DrawPointLine (int x1, int y1, int x2, int y2)
 Draw a line made of braille dots.
void DrawPointLine (int x1, int y1, int x2, int y2, const Stylizer &s)
 Draw a line made of braille dots.
void DrawPointLine (int x1, int y1, int x2, int y2, const Color &color)
 Draw a line made of braille dots.
void DrawPointCircle (int x, int y, int radius)
 Draw a circle made of braille dots.
void DrawPointCircle (int x, int y, int radius, const Stylizer &s)
 Draw a circle made of braille dots.
void DrawPointCircle (int x, int y, int radius, const Color &color)
 Draw a circle made of braille dots.
void DrawPointCircleFilled (int x, int y, int radius)
 Draw a filled circle made of braille dots.
void DrawPointCircleFilled (int x, int y, int radius, const Stylizer &s)
 Draw a filled circle made of braille dots.
void DrawPointCircleFilled (int x, int y, int radius, const Color &color)
 Draw a filled circle made of braille dots.
void DrawPointEllipse (int x, int y, int r1, int r2)
 Draw an ellipse made of braille dots.
void DrawPointEllipse (int x, int y, int r1, int r2, const Color &color)
 Draw an ellipse made of braille dots.
void DrawPointEllipse (int x, int y, int r1, int r2, const Stylizer &s)
 Draw an ellipse made of braille dots.
void DrawPointEllipseFilled (int x, int y, int r1, int r2)
 Draw a filled ellipse made of braille dots.
void DrawPointEllipseFilled (int x, int y, int r1, int r2, const Color &color)
 Draw a filled ellipse made of braille dots.
void DrawPointEllipseFilled (int x, int y, int r1, int r2, const Stylizer &s)
 Draw a filled ellipse made of braille dots.
void DrawBlockOn (int x, int y)
 Draw a block.
void DrawBlockOff (int x, int y)
 Erase a block.
void DrawBlockToggle (int x, int y)
 Toggle a block. If it is filled, it will be erased. If it is empty, it will be filled.
void DrawBlock (int x, int y, bool value)
 Draw a block.
void DrawBlock (int x, int y, bool value, const Stylizer &s)
 Draw a block.
void DrawBlock (int x, int y, bool value, const Color &color)
 Draw a block.
void DrawBlockLine (int x1, int y1, int x2, int y2)
 Draw a line made of block characters.
void DrawBlockLine (int x1, int y1, int x2, int y2, const Stylizer &s)
 Draw a line made of block characters.
void DrawBlockLine (int x1, int y1, int x2, int y2, const Color &color)
 Draw a line made of block characters.
void DrawBlockCircle (int x1, int y1, int radius)
 Draw a circle made of block characters.
void DrawBlockCircle (int x1, int y1, int radius, const Stylizer &s)
 Draw a circle made of block characters.
void DrawBlockCircle (int x1, int y1, int radius, const Color &color)
 Draw a circle made of block characters.
void DrawBlockCircleFilled (int x1, int y1, int radius)
 Draw a filled circle made of block characters.
void DrawBlockCircleFilled (int x1, int y1, int radius, const Stylizer &s)
 Draw a filled circle made of block characters.
void DrawBlockCircleFilled (int x1, int y1, int radius, const Color &color)
 Draw a filled circle made of block characters.
void DrawBlockEllipse (int x1, int y1, int r1, int r2)
 Draw an ellipse made of block characters.
void DrawBlockEllipse (int x1, int y1, int r1, int r2, const Stylizer &s)
 Draw an ellipse made of block characters.
void DrawBlockEllipse (int x1, int y1, int r1, int r2, const Color &color)
 Draw an ellipse made of block characters.
void DrawBlockEllipseFilled (int x1, int y1, int r1, int r2)
 Draw a filled ellipse made of block characters.
void DrawBlockEllipseFilled (int x1, int y1, int r1, int r2, const Stylizer &s)
 Draw a filled ellipse made of block characters.
void DrawBlockEllipseFilled (int x1, int y1, int r1, int r2, const Color &color)
 Draw a filled ellipse made of block characters.
void DrawText (int x, int y, const std::string &value)
 Draw a piece of text.
void DrawText (int x, int y, const std::string &value, const Color &color)
 Draw a piece of text.
void DrawText (int x, int y, const std::string &value, const Stylizer &style)
 Draw a piece of text.
void Style (int x, int y, const Stylizer &style)
 Modify a pixel at a given location.

Detailed Description

Member Typedef Documentation

◆ Stylizer

using Stylizer = std::function<void(Pixel&)>

Definition at line 33 of file canvas.hpp.

Constructor & Destructor Documentation

◆ Canvas() [1/2]

Canvas ( )
default

◆ Canvas() [2/2]

Canvas ( int width,
int height )

Constructor.

Parameters
widththe width of the canvas. A cell is a 2x4 braille dot.
heightthe height of the canvas. A cell is a 2x4 braille dot.

Definition at line 87 of file canvas.cpp.

Member Function Documentation

◆ width()

int width ( ) const
inline

Definition at line 29 of file canvas.hpp.

◆ height()

int height ( ) const
inline

Definition at line 30 of file canvas.hpp.

◆ GetPixel()

Pixel GetPixel ( int x,
int y ) const

Get the content of a cell.

Parameters
xthe x coordinate of the cell.
ythe y coordinate of the cell.

Definition at line 95 of file canvas.cpp.

◆ DrawPointOn()

void DrawPointOn ( int x,
int y )

Draw a braille dot.

Parameters
xthe x coordinate of the dot.
ythe y coordinate of the dot.

Definition at line 134 of file canvas.cpp.

◆ DrawPointOff()

void DrawPointOff ( int x,
int y )

Erase a braille dot.

Parameters
xthe x coordinate of the dot.
ythe y coordinate of the dot.

Definition at line 151 of file canvas.cpp.

◆ DrawPointToggle()

void DrawPointToggle ( int x,
int y )

Toggle a braille dot. A filled one will be erased, and the other will be drawn.

Parameters
xthe x coordinate of the dot.
ythe y coordinate of the dot.

Definition at line 169 of file canvas.cpp.

◆ DrawPoint() [1/3]

void DrawPoint ( int x,
int y,
bool value )

Draw a braille dot.

Parameters
xthe x coordinate of the dot.
ythe y coordinate of the dot.
valuewhether the dot is filled or not.

Definition at line 104 of file canvas.cpp.

◆ DrawPoint() [2/3]

void DrawPoint ( int x,
int y,
bool value,
const Stylizer & style )

Draw a braille dot.

Parameters
xthe x coordinate of the dot.
ythe y coordinate of the dot.
valuewhether the dot is filled or not.
stylethe style of the cell.

Definition at line 122 of file canvas.cpp.

◆ DrawPoint() [3/3]

void DrawPoint ( int x,
int y,
bool value,
const Color & color )

Draw a braille dot.

Parameters
xthe x coordinate of the dot.
ythe y coordinate of the dot.
valuewhether the dot is filled or not.
colorthe color of the dot.

Definition at line 113 of file canvas.cpp.

◆ DrawPointLine() [1/3]

void DrawPointLine ( int x1,
int y1,
int x2,
int y2 )

Draw a line made of braille dots.

Parameters
x1the x coordinate of the first dot.
y1the y coordinate of the first dot.
x2the x coordinate of the second dot.
y2the y coordinate of the second dot.

Definition at line 188 of file canvas.cpp.

◆ DrawPointLine() [2/3]

void DrawPointLine ( int x1,
int y1,
int x2,
int y2,
const Stylizer & style )

Draw a line made of braille dots.

Parameters
x1the x coordinate of the first dot.
y1the y coordinate of the first dot.o
x2the x coordinate of the second dot.
y2the y coordinate of the second dot.
stylethe style of the line.

Definition at line 209 of file canvas.cpp.

◆ DrawPointLine() [3/3]

void DrawPointLine ( int x1,
int y1,
int x2,
int y2,
const Color & color )

Draw a line made of braille dots.

Parameters
x1the x coordinate of the first dot.
y1the y coordinate of the first dot.
x2the x coordinate of the second dot.
y2the y coordinate of the second dot.
colorthe color of the line.

Definition at line 198 of file canvas.cpp.

◆ DrawPointCircle() [1/3]

void DrawPointCircle ( int x,
int y,
int radius )

Draw a circle made of braille dots.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.

Definition at line 246 of file canvas.cpp.

◆ DrawPointCircle() [2/3]

void DrawPointCircle ( int x,
int y,
int radius,
const Stylizer & style )

Draw a circle made of braille dots.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.
stylethe style of the circle.

Definition at line 265 of file canvas.cpp.

◆ DrawPointCircle() [3/3]

void DrawPointCircle ( int x,
int y,
int radius,
const Color & color )

Draw a circle made of braille dots.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.
colorthe color of the circle.

Definition at line 255 of file canvas.cpp.

◆ DrawPointCircleFilled() [1/3]

void DrawPointCircleFilled ( int x,
int y,
int radius )

Draw a filled circle made of braille dots.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.

Definition at line 273 of file canvas.cpp.

◆ DrawPointCircleFilled() [2/3]

void DrawPointCircleFilled ( int x,
int y,
int radius,
const Stylizer & style )

Draw a filled circle made of braille dots.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.
stylethe style of the circle.

Definition at line 295 of file canvas.cpp.

◆ DrawPointCircleFilled() [3/3]

void DrawPointCircleFilled ( int x,
int y,
int radius,
const Color & color )

Draw a filled circle made of braille dots.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.
colorthe color of the circle.

Definition at line 282 of file canvas.cpp.

◆ DrawPointEllipse() [1/3]

void DrawPointEllipse ( int x,
int y,
int r1,
int r2 )

Draw an ellipse made of braille dots.

Parameters
xthe x coordinate of the center of the ellipse.
ythe y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.

Definition at line 307 of file canvas.cpp.

◆ DrawPointEllipse() [2/3]

void DrawPointEllipse ( int x,
int y,
int r1,
int r2,
const Color & color )

Draw an ellipse made of braille dots.

Parameters
xthe x coordinate of the center of the ellipse.
ythe y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.
colorthe color of the ellipse.

Definition at line 317 of file canvas.cpp.

◆ DrawPointEllipse() [3/3]

void DrawPointEllipse ( int x1,
int y1,
int r1,
int r2,
const Stylizer & s )

Draw an ellipse made of braille dots.

Parameters
x1the x coordinate of the center of the ellipse.
y1the y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.
sthe style of the ellipse.

Definition at line 332 of file canvas.cpp.

◆ DrawPointEllipseFilled() [1/3]

void DrawPointEllipseFilled ( int x1,
int y1,
int r1,
int r2 )

Draw a filled ellipse made of braille dots.

Parameters
x1the x coordinate of the center of the ellipse.
y1the y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.

Definition at line 371 of file canvas.cpp.

◆ DrawPointEllipseFilled() [2/3]

void DrawPointEllipseFilled ( int x1,
int y1,
int r1,
int r2,
const Color & color )

Draw a filled ellipse made of braille dots.

Parameters
x1the x coordinate of the center of the ellipse.
y1the y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.
colorthe color of the ellipse.

Definition at line 381 of file canvas.cpp.

◆ DrawPointEllipseFilled() [3/3]

void DrawPointEllipseFilled ( int x1,
int y1,
int r1,
int r2,
const Stylizer & s )

Draw a filled ellipse made of braille dots.

Parameters
x1the x coordinate of the center of the ellipse.
y1the y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.
sthe style of the ellipse.

Definition at line 396 of file canvas.cpp.

◆ DrawBlockOn()

void DrawBlockOn ( int x,
int y )

Draw a block.

Parameters
xthe x coordinate of the block.
ythe y coordinate of the block.

Definition at line 465 of file canvas.cpp.

◆ DrawBlockOff()

void DrawBlockOff ( int x,
int y )

Erase a block.

Parameters
xthe x coordinate of the block.
ythe y coordinate of the block.

Definition at line 485 of file canvas.cpp.

◆ DrawBlockToggle()

void DrawBlockToggle ( int x,
int y )

Toggle a block. If it is filled, it will be erased. If it is empty, it will be filled.

Parameters
xthe x coordinate of the block.
ythe y coordinate of the block.

Definition at line 506 of file canvas.cpp.

◆ DrawBlock() [1/3]

void DrawBlock ( int x,
int y,
bool value )

Draw a block.

Parameters
xthe x coordinate of the block.
ythe y coordinate of the block.
valuewhether the block is filled or not.

Definition at line 435 of file canvas.cpp.

◆ DrawBlock() [2/3]

void DrawBlock ( int x,
int y,
bool value,
const Stylizer & style )

Draw a block.

Parameters
xthe x coordinate of the block.
ythe y coordinate of the block.
valuewhether the block is filled or not.
stylethe style of the block.

Definition at line 453 of file canvas.cpp.

◆ DrawBlock() [3/3]

void DrawBlock ( int x,
int y,
bool value,
const Color & color )

Draw a block.

Parameters
xthe x coordinate of the block.
ythe y coordinate of the block.
valuewhether the block is filled or not.
colorthe color of the block.

Definition at line 444 of file canvas.cpp.

◆ DrawBlockLine() [1/3]

void DrawBlockLine ( int x1,
int y1,
int x2,
int y2 )

Draw a line made of block characters.

Parameters
x1the x coordinate of the first point of the line.
y1the y coordinate of the first point of the line.
x2the x coordinate of the second point of the line.
y2the y coordinate of the second point of the line.

Definition at line 528 of file canvas.cpp.

◆ DrawBlockLine() [2/3]

void DrawBlockLine ( int x1,
int y1,
int x2,
int y2,
const Stylizer & style )

Draw a line made of block characters.

Parameters
x1the x coordinate of the first point of the line.
y1the y coordinate of the first point of the line.
x2the x coordinate of the second point of the line.
y2the y coordinate of the second point of the line.
stylethe style of the line.

Definition at line 549 of file canvas.cpp.

◆ DrawBlockLine() [3/3]

void DrawBlockLine ( int x1,
int y1,
int x2,
int y2,
const Color & color )

Draw a line made of block characters.

Parameters
x1the x coordinate of the first point of the line.
y1the y coordinate of the first point of the line.
x2the x coordinate of the second point of the line.
y2the y coordinate of the second point of the line.
colorthe color of the line.

Definition at line 538 of file canvas.cpp.

◆ DrawBlockCircle() [1/3]

void DrawBlockCircle ( int x,
int y,
int radius )

Draw a circle made of block characters.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.

Definition at line 589 of file canvas.cpp.

◆ DrawBlockCircle() [2/3]

void DrawBlockCircle ( int x,
int y,
int radius,
const Stylizer & style )

Draw a circle made of block characters.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.
stylethe style of the circle.

Definition at line 608 of file canvas.cpp.

◆ DrawBlockCircle() [3/3]

void DrawBlockCircle ( int x,
int y,
int radius,
const Color & color )

Draw a circle made of block characters.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.
colorthe color of the circle.

Definition at line 598 of file canvas.cpp.

◆ DrawBlockCircleFilled() [1/3]

void DrawBlockCircleFilled ( int x,
int y,
int radius )

Draw a filled circle made of block characters.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.

Definition at line 616 of file canvas.cpp.

◆ DrawBlockCircleFilled() [2/3]

void DrawBlockCircleFilled ( int x,
int y,
int radius,
const Stylizer & s )

Draw a filled circle made of block characters.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.
sthe style of the circle.

Definition at line 638 of file canvas.cpp.

◆ DrawBlockCircleFilled() [3/3]

void DrawBlockCircleFilled ( int x,
int y,
int radius,
const Color & color )

Draw a filled circle made of block characters.

Parameters
xthe x coordinate of the center of the circle.
ythe y coordinate of the center of the circle.
radiusthe radius of the circle.
colorthe color of the circle.

Definition at line 625 of file canvas.cpp.

◆ DrawBlockEllipse() [1/3]

void DrawBlockEllipse ( int x,
int y,
int r1,
int r2 )

Draw an ellipse made of block characters.

Parameters
xthe x coordinate of the center of the ellipse.
ythe y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.

Definition at line 650 of file canvas.cpp.

◆ DrawBlockEllipse() [2/3]

void DrawBlockEllipse ( int x1,
int y1,
int r1,
int r2,
const Stylizer & s )

Draw an ellipse made of block characters.

Parameters
x1the x coordinate of the center of the ellipse.
y1the y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.
sthe style of the ellipse.

Definition at line 675 of file canvas.cpp.

◆ DrawBlockEllipse() [3/3]

void DrawBlockEllipse ( int x,
int y,
int r1,
int r2,
const Color & color )

Draw an ellipse made of block characters.

Parameters
xthe x coordinate of the center of the ellipse.
ythe y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.
colorthe color of the ellipse.

Definition at line 660 of file canvas.cpp.

◆ DrawBlockEllipseFilled() [1/3]

void DrawBlockEllipseFilled ( int x,
int y,
int r1,
int r2 )

Draw a filled ellipse made of block characters.

Parameters
xthe x coordinate of the center of the ellipse.
ythe y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.

Definition at line 716 of file canvas.cpp.

◆ DrawBlockEllipseFilled() [2/3]

void DrawBlockEllipseFilled ( int x1,
int y1,
int r1,
int r2,
const Stylizer & s )

Draw a filled ellipse made of block characters.

Parameters
x1the x coordinate of the center of the ellipse.
y1the y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.
sthe style of the ellipse.

Definition at line 741 of file canvas.cpp.

◆ DrawBlockEllipseFilled() [3/3]

void DrawBlockEllipseFilled ( int x,
int y,
int r1,
int r2,
const Color & color )

Draw a filled ellipse made of block characters.

Parameters
xthe x coordinate of the center of the ellipse.
ythe y coordinate of the center of the ellipse.
r1the radius of the ellipse along the x axis.
r2the radius of the ellipse along the y axis.
colorthe color of the ellipse.

Definition at line 726 of file canvas.cpp.

◆ DrawText() [1/3]

void DrawText ( int x,
int y,
const std::string & value )

Draw a piece of text.

Parameters
xthe x coordinate of the text.
ythe y coordinate of the text.
valuethe text to draw.

Definition at line 782 of file canvas.cpp.

◆ DrawText() [2/3]

void DrawText ( int x,
int y,
const std::string & value,
const Color & color )

Draw a piece of text.

Parameters
xthe x coordinate of the text.
ythe y coordinate of the text.
valuethe text to draw.
colorthe color of the text.

Definition at line 791 of file canvas.cpp.

◆ DrawText() [3/3]

void DrawText ( int x,
int y,
const std::string & value,
const Stylizer & style )

Draw a piece of text.

Parameters
xthe x coordinate of the text.
ythe y coordinate of the text.
valuethe text to draw.
stylethe style of the text.

Definition at line 803 of file canvas.cpp.

◆ Style()

void Style ( int x,
int y,
const Stylizer & style )

Modify a pixel at a given location.

Parameters
stylea function that modifies the pixel.

Definition at line 822 of file canvas.cpp.


The documentation for this struct was generated from the following files: