Advertisement
Guest User

Canvas.h

a guest
Apr 19th, 2019
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. #pragma once
  2. #include <Windows.h>
  3. #include <utility>
  4. #include <vector>
  5.  
  6. #include "Sprite.h"
  7.  
  8.  
  9. namespace ulib
  10. {
  11.  
  12.     namespace canvas
  13.     {
  14.         using position = std::pair<int, int>;
  15.  
  16.  
  17.         enum TEXT_ATTRIBUTES
  18.         {
  19.             TEXT_DARKBLUE  = 0x0001,
  20.             TEXT_DARKGREEN = 0x0002,
  21.             TEXT_DARKRED   = 0x0004,
  22.             TEXT_INTENSITY = 0x0004,
  23.         };
  24.  
  25.  
  26.         enum BACKDROP_ATTRIBUTES
  27.         {
  28.             BACKDROP_BLUE      = 0x0010,
  29.             BACKDROP_GREEN     = 0x0020,
  30.             BACKDROP_RED       = 0x0040,
  31.             BACKDROP_INTENSITY = 0x0040,
  32.         };
  33.  
  34.        
  35.  
  36.  
  37.         struct WindowInfo
  38.         {
  39.             HANDLE WriteHandle;
  40.             HANDLE ReadHandle;
  41.             SMALL_RECT WindowSize;
  42.             COORD BufferSize;
  43.             COORD CharBufferSize;
  44.             COORD CharPosition;
  45.             SMALL_RECT WriteArea;
  46.             CHAR_INFO *Buffer;
  47.  
  48.             ~WindowInfo()
  49.             {
  50.                 delete Buffer;
  51.             }
  52.         };
  53.  
  54.  
  55.  
  56.  
  57.         class Canvas
  58.         {
  59.         private:
  60.             WindowInfo info;
  61.             std::vector<Sprite> sprites;
  62.             std::vector<Shader> shaders;
  63.  
  64.         public:
  65.             Canvas(short width, short height)
  66.             {
  67.                 Init(width, height);
  68.             }
  69.  
  70.             void Init(short width, short height);
  71.  
  72.             void Update();
  73.  
  74.             void Clear();
  75.  
  76.             void Display();
  77.  
  78.             void Draw(Sprite&, const unsigned short& = 1, position = { 0, 0 });
  79.             void Draw(const std::string&, const unsigned short& = 0x0004, position = { 0, 0 });
  80.             void Draw(const std::vector<std::string>&, const unsigned short& = 1, position = { 0, 0 });
  81.         };
  82.  
  83.     }
  84.     using namespace canvas;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement