summaryrefslogtreecommitdiff
path: root/src/gui/game/Brush.cpp
blob: 9f2f2a8bb0355d582162657246ee7ba813558c8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "Brush.h"
#include "graphics/Renderer.h"

void Brush::RenderRect(Renderer * ren, ui::Point position1, ui::Point position2)
{
	int width, height, t;
	width = position2.X-position1.X;
	height = position2.Y-position1.Y;
	if(height<0)
	{
		position1.Y += height;
		height *= -1;
	}
	if(width<0)
	{
		position1.X += width;
		width *= -1;
	}
	
	ren->xor_line(position1.X, position1.Y, position1.X+width, position1.Y);
	if(height>0){
		ren->xor_line(position1.X, position1.Y+height, position1.X+width, position1.Y+height);
		if(height>1){
			ren->xor_line(position1.X+width, position1.Y+1, position1.X+width, position1.Y+height-1);
			if(width>0)
				ren->xor_line(position1.X, position1.Y+1, position1.X, position1.Y+height-1);
		}
	}
}

void Brush::RenderLine(Renderer * ren, ui::Point position1, ui::Point position2)
{
	ren->xor_line(position1.X, position1.Y, position2.X, position2.Y);
}

void Brush::RenderPoint(Renderer * ren, ui::Point position)
{
	if(!outline)
		updateOutline();
	if(!outline)
		return;
	ren->xor_bitmap(outline, position.X-radius.X, position.Y-radius.Y, size.X, size.Y);
}

void Brush::RenderFill(Renderer * ren, ui::Point position)
{
	ren->xor_line(position.X-5, position.Y, position.X-1, position.Y);
	ren->xor_line(position.X+5, position.Y, position.X+1, position.Y);
	ren->xor_line(position.X, position.Y-5, position.X, position.Y-1);
	ren->xor_line(position.X, position.Y+5, position.X, position.Y+1);
}