You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

5 years ago
  1. #pragma once
  2. #include "CELLMath.hpp"
  3. namespace CELL
  4. {
  5. class Raster
  6. {
  7. public:
  8. Rgba _buffer[256][256];
  9. public:
  10. Raster();
  11. ~Raster(void);
  12. void clear()
  13. {
  14. memset(_buffer,0,sizeof(_buffer));
  15. }
  16. void drawPoint(int x,int y, Rgba color,int ptSize)
  17. {
  18. switch(ptSize)
  19. {
  20. case 1:
  21. setPixel(x,y,color);
  22. break;
  23. case 2:
  24. setPixel(x + 0, y + 0,color);
  25. setPixel(x + 1, y + 0,color);
  26. setPixel(x + 0, y + 1,color);
  27. setPixel(x + 1, y + 1,color);
  28. break;
  29. case 3:
  30. setPixel(x - 1, y - 1,color);
  31. setPixel(x + 0, y - 1,color);
  32. setPixel(x + 1, y - 1,color);
  33. setPixel(x - 1, y + 0,color);
  34. setPixel(x + 0, y + 0,color);
  35. setPixel(x + 1, y + 0,color);
  36. setPixel(x - 1, y + 1,color);
  37. setPixel(x + 0, y + 1,color);
  38. setPixel(x + 1, y + 1,color);
  39. break;
  40. }
  41. }
  42. void setPixel(int x,int y,Rgba color)
  43. {
  44. if (x < 0 || y < 0 || x >= 256 || y >= 256)
  45. {
  46. return;
  47. }
  48. _buffer[y][x] = color;
  49. }
  50. };
  51. }