2017-08-30 18:31:27 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "DrawCommand.h"
|
|
|
|
|
|
|
|
class DrawRectangleCommand : public DrawCommand
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
int _x, _y, _width, _height, _color;
|
|
|
|
bool _fill;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void InternalDraw()
|
|
|
|
{
|
|
|
|
if(_fill) {
|
|
|
|
for(int j = 0; j < _height; j++) {
|
|
|
|
for(int i = 0; i < _width; i++) {
|
|
|
|
DrawPixel(_x + i, _y + j, _color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for(int i = 0; i < _width; i++) {
|
|
|
|
DrawPixel(_x + i, _y, _color);
|
|
|
|
DrawPixel(_x + i, _y + _height - 1, _color);
|
|
|
|
}
|
2017-09-02 10:36:57 -04:00
|
|
|
for(int i = 1; i < _height - 1; i++) {
|
2017-08-30 18:31:27 -04:00
|
|
|
DrawPixel(_x, _y + i, _color);
|
|
|
|
DrawPixel(_x + _width - 1, _y + i, _color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-07-01 15:21:05 -04:00
|
|
|
DrawRectangleCommand(int x, int y, int width, int height, int color, bool fill, int frameCount, int startFrame) :
|
|
|
|
DrawCommand(startFrame, frameCount), _x(x), _y(y), _width(width), _height(height), _color(color), _fill(fill)
|
2017-08-30 18:31:27 -04:00
|
|
|
{
|
2018-06-17 13:32:18 -04:00
|
|
|
if(width < 0) {
|
2018-06-19 00:16:30 -04:00
|
|
|
_x += width + 1;
|
2018-06-17 13:32:18 -04:00
|
|
|
_width = -width;
|
|
|
|
}
|
|
|
|
if(height < 0) {
|
2018-06-19 00:16:30 -04:00
|
|
|
_y += height + 1;
|
2018-06-17 13:32:18 -04:00
|
|
|
_height = -height;
|
|
|
|
}
|
|
|
|
|
2017-09-02 10:36:57 -04:00
|
|
|
//Invert alpha byte - 0 = opaque, 255 = transparent (this way, no need to specifiy alpha channel all the time)
|
|
|
|
_color = (~color & 0xFF000000) | (color & 0xFFFFFF);
|
2017-08-30 18:31:27 -04:00
|
|
|
}
|
|
|
|
};
|