/*! \file * \brief Graphics primitives like \ref Point */ #pragma once /*! \brief Coordinate on the graphic screen * \ingroup gfx */ struct Point { /*! \brief X Position */ int x; /*! \brief X Position */ int y; /*! \brief Default Constructor * * Initializing the point to the initial position (0, 0) */ Point() : x(0), y(0) {} /*! \brief Constructor * * \brief x X Position * \brief y Y Position */ Point(int x, int y) : x(x), y(y) {} /*! \brief Summation of two points */ Point operator+(const Point& that) const { return Point(x + that.x, y + that.y); } /*! \brief Assignment summation of two points */ Point& operator+=(const Point& that) { x += that.x; y += that.y; return *this; } /*! \brief Difference of two points */ Point operator-(const Point& that) const { return Point(x - that.x, y - that.y); } /*! \brief Assignment difference of two points */ Point& operator-=(const Point& that) { x -= that.x; y -= that.y; return *this; } }; /*! \brief Color modes * \ingroup gfx */ enum SpriteColorMode { RGB, ///< Additive color mode (red, green & blue) GREYSCALE, ///< Greyscale }; /*! \brief Sprite pixel component * \ingroup gfx * * \tparam BITS mask size */ template struct __attribute__((packed)) SpritePixelComponent { /*! \brief Sprite pixel component value */ unsigned int value : BITS; /*! \brief Default constructor * (sets initial value to zero) */ SpritePixelComponent() : value(0) {} /*! \brief Constructor * * \param value Value for component */ explicit SpritePixelComponent(unsigned int value) : value(value) {} }; template struct __attribute__((packed)) SpritePixel; /*! \brief Colored pixel with transparency * \ingroup gfx * * \tparam BITS Size of mask */ template struct __attribute__((packed)) SpritePixel { SpritePixelComponent red; SpritePixelComponent green; SpritePixelComponent blue; SpritePixelComponent alpha; SpritePixel(unsigned red, unsigned green, unsigned blue, unsigned alpha) : red(red), green(green), blue(blue), alpha(alpha) {} SpritePixel() {} }; /*! \brief Colored pixel without transparency * \ingroup gfx * * \tparam BITS Size of mask */ template struct __attribute__((packed)) SpritePixel { SpritePixelComponent red; SpritePixelComponent green; SpritePixelComponent blue; SpritePixel(unsigned red, unsigned green, unsigned blue) : red(red), green(green), blue(blue) {} SpritePixel() {} }; /*! \brief Greyscale pixel with transparency * \ingroup gfx * * \tparam BITS Size of mask */ template struct __attribute__((packed)) SpritePixel { SpritePixelComponent luminance; SpritePixelComponent alpha; SpritePixel(unsigned luminance, unsigned alpha) : luminance(luminance), alpha(alpha) {} SpritePixel() {} }; /*! \brief Greyscale pixel without transparency * \ingroup gfx * * \tparam BITS Size of mask */ template struct __attribute__((packed)) SpritePixel { SpritePixelComponent luminance; explicit SpritePixel(unsigned luminance) : luminance(luminance) {} SpritePixel() {} }; typedef struct SpritePixel Color; typedef struct SpritePixel ColorAlpha; /*! \brief GIMP image * \ingroup gfx * * Image exported as C-source (without `Glib` types!) in * [GIMP](https://www.gimp.org/), supports alpha blending (transparency). */ struct GIMP { unsigned int width; unsigned int height; unsigned int bytes_per_pixel; unsigned char pixel_data[]; };