cppgfx
0.1.0
C++17 educational graphics library
|
Drawing primitives and styles. More...
Functions | |
void | cppgfx::App::background (const sf::Color &color) |
Set the background color of the window for the current frame. More... | |
void | cppgfx::App::background (uint8_t shade) |
Set the background color of the window for the current frame. More... | |
void | cppgfx::App::background (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Set the background color of the window. More... | |
void | cppgfx::App::fill (const sf::Color &color) |
Set the infill color for primitives. More... | |
void | cppgfx::App::fill (uint8_t shade) |
Set the infill color for primitives. More... | |
void | cppgfx::App::fill (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Set the infill color for primitives. More... | |
void | cppgfx::App::noFill () |
Disable the infill color for primitives. | |
void | cppgfx::App::stroke (const sf::Color &color) |
Set the outline color for primitives. | |
void | cppgfx::App::stroke (uint8_t shade) |
Set the outline color for primitives. More... | |
void | cppgfx::App::stroke (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Set the outline color for primitives. More... | |
void | cppgfx::App::noStroke () |
Disable the outline color for primitives. | |
void | cppgfx::App::strokeWeight (float weight) |
Set the thickness of the outline for primitives. More... | |
void | cppgfx::App::push () |
Push the current draw style onto the stack. More... | |
void | cppgfx::App::pop () |
Pop the current draw style from the stack. More... | |
void | cppgfx::App::line (float x1, float y1, float x2, float y2) |
Draw a line from (x1, y1) to (x2, y2) More... | |
void | cppgfx::App::lineCap (LineCap cap) |
Set the line cap style. More... | |
void | cppgfx::App::rect (float x, float y, float w, float h) |
Draw a rectangle at (x, y) with the given width and height. More... | |
void | cppgfx::App::rectMode (RectMode mode) |
Where the origin of the rectangle is. More... | |
void | cppgfx::App::circle (float x, float y, float radius) |
Draw a circle at (x, y) with the given radius. More... | |
void | cppgfx::App::ellipse (float x, float y, float w, float h) |
Draw an ellipse at (x, y) with the given width and height. More... | |
void | cppgfx::App::triangle (float x1, float y1, float x2, float y2, float x3, float y3) |
Draw a triangle with the given points. More... | |
void | cppgfx::App::vector (float vectorX, float vectorY, float originX, float originY) |
Draw a vector arrow from the origin to origin + vector. More... | |
void | cppgfx::App::textFont (const sf::Font &font) |
Set the current font to be used for rendering from now on. More... | |
sf::Font | cppgfx::App::loadFont (const std::string &filename) |
Load a font from a file with a specific size. More... | |
void | cppgfx::App::textAlign (TextAlign alignment) |
Set the current alignment for drawing text. More... | |
float | cppgfx::App::textWidth (const std::string &text) |
Calculate the width of a text string in pixels. More... | |
void | cppgfx::App::textSize (uint32_t size) |
Set the font size of the currently active font. More... | |
void | cppgfx::App::text (const std::string &text, float x, float y) |
Draw text at (x, y) More... | |
Drawing primitives and styles.
void cppgfx::App::background | ( | const sf::Color & | color | ) |
Set the background color of the window for the current frame.
color | The background color |
void cppgfx::App::background | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b, | ||
uint8_t | a = 255 |
||
) |
Set the background color of the window.
r | The red component of the background color [0-255] |
g | The green component of the background color [0-255] |
b | The blue component of the background color [0-255] |
a | The alpha component of the background color [0-255] (optional) |
void cppgfx::App::background | ( | uint8_t | shade | ) |
Set the background color of the window for the current frame.
shade | The background color for r, g and b [0-255] |
void cppgfx::App::circle | ( | float | x, |
float | y, | ||
float | radius | ||
) |
Draw a circle at (x, y) with the given radius.
x | The x coordinate of the center of the circle in pixels, relative to the top left corner of the window |
y | The y coordinate of the center of the circle in pixels, relative to the top left corner of the window |
radius | The radius of the circle in pixels |
void cppgfx::App::ellipse | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Draw an ellipse at (x, y) with the given width and height.
x | The x coordinate of the center of the ellipse in pixels, relative to the top left corner of the window |
y | The y coordinate of the center of the ellipse in pixels, relative to the top left corner of the window |
w | The width of the ellipse in pixels |
h | The height of the ellipse in pixels |
void cppgfx::App::fill | ( | const sf::Color & | color | ) |
Set the infill color for primitives.
color | The infill color |
void cppgfx::App::fill | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b, | ||
uint8_t | a = 255 |
||
) |
Set the infill color for primitives.
r | The red component of the infill color [0-255] |
g | The green component of the infill color [0-255] |
b | The blue component of the infill color [0-255] |
a | The alpha component of the infill color [0-255] (optional) |
void cppgfx::App::fill | ( | uint8_t | shade | ) |
Set the infill color for primitives.
shade | The infill color for r, g and b [0-255] |
void cppgfx::App::line | ( | float | x1, |
float | y1, | ||
float | x2, | ||
float | y2 | ||
) |
Draw a line from (x1, y1) to (x2, y2)
x1 | The x coordinate of the first point in pixels, relative to the top left corner of the window |
y1 | The y coordinate of the first point in pixels, relative to the top left corner of the window |
x2 | The x coordinate of the second point in pixels, relative to the top left corner of the window |
y2 | The y coordinate of the second point in pixels, relative to the top left corner of the window |
void cppgfx::App::lineCap | ( | LineCap | cap | ) |
Set the line cap style.
cap | The line cap style |
sf::Font cppgfx::App::loadFont | ( | const std::string & | filename | ) |
Load a font from a file with a specific size.
filename | The filename of the font to load |
void cppgfx::App::pop | ( | ) |
Pop the current draw style from the stack.
This function will pop the current draw style from the stack, so that it can be restored later. This mechanism is very useful when you want to temporarily change the draw style, and later change it back to what it was.
void cppgfx::App::push | ( | ) |
Push the current draw style onto the stack.
This function will push the current draw style onto the stack, so that it can be restored later. This mechanism is very useful when you want to temporarily change the draw style, and later change it back to what it was.
void cppgfx::App::rect | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Draw a rectangle at (x, y) with the given width and height.
What the x, y, w and h parameters mean depends on the current rectMode.
x | The first x coordinate in pixels, relative to the top left corner of the window |
y | The first y coordinate in pixels, relative to the top left corner of the window |
w | The second x coordinate in pixels, relative to the top left corner of the window |
h | The second y coordinate in pixels, relative to the top left corner of the window |
void cppgfx::App::rectMode | ( | RectMode | mode | ) |
Where the origin of the rectangle is.
This function will change the meaning of the x, y, w and h parameters of the rect() function. The default is RectMode::Corner. RectMode::Corner means that x and y are the top left corner of the rectangle and w and h are the width and height of the rectangle. RectMode::Center means that x and y are the center of the rectangle and w and h are the width and height of the rectangle. RectMode::Corners means that x and y are the top left corner of the rectangle and w and h are the bottom right corner of the rectangle.
mode | The rectMode |
void cppgfx::App::stroke | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b, | ||
uint8_t | a = 255 |
||
) |
Set the outline color for primitives.
r | The red component of the outline color [0-255] |
g | The green component of the outline color [0-255] |
b | The blue component of the outline color [0-255] |
a | The alpha component of the outline color [0-255] (optional) |
void cppgfx::App::stroke | ( | uint8_t | shade | ) |
Set the outline color for primitives.
shade | The outline color for r, g and b [0-255] |
void cppgfx::App::strokeWeight | ( | float | weight | ) |
Set the thickness of the outline for primitives.
weight | The thickness of the outline in pixels |
void cppgfx::App::text | ( | const std::string & | text, |
float | x, | ||
float | y | ||
) |
Draw text at (x, y)
text | The text to draw |
x | The x coordinate of the text in pixels, relative to the top left corner of the window |
y | The y coordinate of the text in pixels, relative to the top left corner of the window |
void cppgfx::App::textAlign | ( | TextAlign | alignment | ) |
Set the current alignment for drawing text.
alignment | The alignment |
void cppgfx::App::textFont | ( | const sf::Font & | font | ) |
Set the current font to be used for rendering from now on.
font | The SFML font to use |
void cppgfx::App::textSize | ( | uint32_t | size | ) |
Set the font size of the currently active font.
size | The font size in pixels |
float cppgfx::App::textWidth | ( | const std::string & | text | ) |
Calculate the width of a text string in pixels.
text | The text to measure |
void cppgfx::App::triangle | ( | float | x1, |
float | y1, | ||
float | x2, | ||
float | y2, | ||
float | x3, | ||
float | y3 | ||
) |
Draw a triangle with the given points.
x1 | The x coordinate of the first point in pixels, relative to the top left corner of the window |
y1 | The y coordinate of the first point in pixels, relative to the top left corner of the window |
x2 | The x coordinate of the second point in pixels, relative to the top left corner of the window |
y2 | The y coordinate of the second point in pixels, relative to the top left corner of the window |
x3 | The x coordinate of the third point in pixels, relative to the top left corner of the window |
y3 | The y coordinate of the third point in pixels, relative to the top left corner of the window |
void cppgfx::App::vector | ( | float | vectorX, |
float | vectorY, | ||
float | originX, | ||
float | originY | ||
) |
Draw a vector arrow from the origin to origin + vector.
This function will draw a vector arrow from the origin to origin + vector. It is meant to be used for scientific visualization purposes.
vectorX | The x component of the vector |
vectorY | The y component of the vector |
originX | The x coordinate of the origin of the vector in pixels, relative to the top left corner of the window |
originY | The y coordinate of the origin of the vector in pixels, relative to the top left corner of the window |