forked from FranciscoBiaso/TileMapEditorRealmz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrawingFunctions.cpp
38 lines (35 loc) · 871 Bytes
/
DrawingFunctions.cpp
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
#include "DrawingFunctions.h"
void graphics::drawSquare(cairo_t* cr, int x, int y, int w, int h, GdkRGBA color)
{
cairo_rectangle(cr, x, y, w, h);
cairo_set_source_rgba(cr, color.red, color.green, color.blue, color.alpha);
cairo_fill(cr);
}
void graphics::get_LeftTop_rightbot(glm::vec2 A, glm::vec2 B, glm::vec2& leftTop, glm::vec2& rightBot)
{
if (A.y > B.y && A.x < B.x)
{
leftTop = A;
rightBot = B;
}
if (A.y < B.y && A.x < B.x)
{
leftTop = glm::vec2(A.x, B.y);
rightBot = glm::vec2(B.x, A.y);
}
if (A.y < B.y && A.x > B.x)
{
leftTop = B;
rightBot = A;
}
if (A.y > B.y && A.x > B.x)
{
leftTop = glm::vec2(B.x, A.y);
rightBot = glm::vec2(A.x, B.y);
}
if (A.x == B.x || A.y == B.y)
{
leftTop = A;
rightBot = B;
}
}