forked from plastictown/Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrectf.cpp
More file actions
37 lines (32 loc) · 726 Bytes
/
Copy pathrectf.cpp
File metadata and controls
37 lines (32 loc) · 726 Bytes
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
/*
* https://github.com/plastictown/Engine
* Copyright (C) 2018 Mikhail Domchenkov
*/
#include <rectf.h>
bool Rectf::pointInRect(const Point2f& pt) const noexcept
{
bool bX = right_bottom.x - pt.x >= left_top.x;
bool bY = right_bottom.y - pt.y >= left_top.y;
return (bX && bY);
}
Rectf::Rectf(const Rectf& r)
{
*this = r;
}
Rectf& Rectf::operator = (const Rectf& r)
{
if (this == &r) return *this;
left_top = r.left_top;
right_bottom = r.right_bottom;
return *this;
}
void Rectf::heightByAspect(GLfloat aspect)
{
if(aspect == 0) return;
right_bottom.y = right_bottom.x / aspect;
}
void Rectf::widthByAspect(GLfloat aspect)
{
if(aspect == 0) return;
right_bottom.x = right_bottom.y * aspect;
}