5#include "fifechan/graphics.hpp"
10#include "fifechan/cliprectangle.hpp"
11#include "fifechan/exception.hpp"
12#include "fifechan/font.hpp"
13#include "fifechan/image.hpp"
14#include "fifechan/rectangle.hpp"
59 throwException(
"Tried to pop clip area from empty stack.");
68 throwException(
"The clip area stack is empty.");
93 if (
mFont ==
nullptr) {
94 throwException(
"No font set.");
99 mFont->drawString(
this, text, x, y);
101 case Alignment::Center:
102 mFont->drawString(
this, text, x - (
mFont->getWidth(text) / 2), y);
104 case Alignment::Right:
105 mFont->drawString(
this, text, x -
mFont->getWidth(text), y);
108 throwException(
"Unknown alignment.");
A rectangle specifically used for clipping rendering regions.
int xOffset
Holds the x offset of the x coordinate.
int yOffset
Holds the y offset of the y coordinate.
Abstract interface for font rendering.
Font * mFont
Holds the current font.
Alignment
Alignments for text drawing.
virtual void popClipArea()
Removes the top most clip area from the stack.
virtual void drawImage(Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height)=0
Draws a part of an image.
void drawText(std::string const &text, int x, int y)
Draws text with a default left alignment.
virtual ClipRectangle const & getCurrentClipArea()
Gets the current clip area.
virtual bool pushClipArea(Rectangle area)
Pushes a clip area onto the stack.
virtual void setFont(Font *font)
Sets the font to use when drawing text.
virtual std::shared_ptr< Font > createFont(std::string const &filename, int size)
Creates a font for this graphics backend.
std::stack< ClipRectangle > mClipStack
Holds the clip area stack.
Abstract holder for image data.
virtual int getHeight() const =0
Gets the height of the image.
virtual int getWidth() const =0
Gets the width of the image.
Represents a rectangular area (X, Y, Width, Height).
int width
Holds the width of the rectangle.
Rectangle intersection(Rectangle const &rh) const
Gets the intersection between two rectangles.
int y
Holds the x coordinate of the rectangle.
int x
Holds the x coordinate of the rectangle.
int height
Holds the height of the rectangle.
bool isEmpty() const
Checks whether the rectangle is empty or not.