mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Added Rect2 <-> Rect2i conversion operators. Also smaller helper methods.
This commit is contained in:
parent
334075aeca
commit
cf8dd43fd7
@ -1,6 +1,7 @@
|
||||
#include "rect2.h"
|
||||
|
||||
#include "math.h"
|
||||
#include "rect2i.h"
|
||||
|
||||
float Rect2::get_area() const {
|
||||
return w * h;
|
||||
@ -161,6 +162,10 @@ bool operator!=(const Rect2 &a, const Rect2 &b) {
|
||||
return !a.is_equal_approx(b);
|
||||
}
|
||||
|
||||
Rect2::operator Rect2i() const {
|
||||
return Rect2i(x, y, w, h);
|
||||
}
|
||||
|
||||
Rect2::Rect2() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "vector2.h"
|
||||
#include "math.h"
|
||||
|
||||
class Rect2i;
|
||||
|
||||
class Rect2 {
|
||||
public:
|
||||
float get_area() const;
|
||||
@ -32,6 +34,8 @@ public:
|
||||
friend bool operator==(const Rect2 &a, const Rect2 &b);
|
||||
friend bool operator!=(const Rect2 &a, const Rect2 &b);
|
||||
|
||||
operator Rect2i() const;
|
||||
|
||||
Rect2();
|
||||
Rect2(const Rect2 &b);
|
||||
Rect2(const float rx, const float ry);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "rect2i.h"
|
||||
|
||||
#include "math.h"
|
||||
#include "rect2.h"
|
||||
|
||||
float Rect2i::get_area() const {
|
||||
return w * h;
|
||||
@ -161,6 +162,10 @@ bool operator!=(const Rect2i &a, const Rect2i &b) {
|
||||
return !a.is_equal_approx(b);
|
||||
}
|
||||
|
||||
Rect2i::operator Rect2() const {
|
||||
return Rect2(x, y, w, h);
|
||||
}
|
||||
|
||||
Rect2i::Rect2i() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
@ -195,3 +200,24 @@ Rect2i::Rect2i(const Vector2i &position, const Vector2i &size) {
|
||||
w = size.x;
|
||||
h = size.y;
|
||||
}
|
||||
|
||||
Rect2i::Rect2i(const Vector2 &position, const Vector2 &size) {
|
||||
x = position.x;
|
||||
y = position.y;
|
||||
w = size.x;
|
||||
h = size.y;
|
||||
}
|
||||
|
||||
Rect2i::Rect2i(const Vector2i &position, const Vector2 &size) {
|
||||
x = position.x;
|
||||
y = position.y;
|
||||
w = size.x;
|
||||
h = size.y;
|
||||
}
|
||||
|
||||
Rect2i::Rect2i(const Vector2 &position, const Vector2i &size) {
|
||||
x = position.x;
|
||||
y = position.y;
|
||||
w = size.x;
|
||||
h = size.y;
|
||||
}
|
||||
|
@ -2,8 +2,11 @@
|
||||
#define RECT2I_H
|
||||
|
||||
#include "vector2i.h"
|
||||
#include "vector2.h"
|
||||
#include "math.h"
|
||||
|
||||
class Rect2;
|
||||
|
||||
class Rect2i {
|
||||
public:
|
||||
float get_area() const;
|
||||
@ -32,11 +35,16 @@ public:
|
||||
friend bool operator==(const Rect2i &a, const Rect2i &b);
|
||||
friend bool operator!=(const Rect2i &a, const Rect2i &b);
|
||||
|
||||
operator Rect2() const;
|
||||
|
||||
Rect2i();
|
||||
Rect2i(const Rect2i &b);
|
||||
Rect2i(const int rx, const int ry);
|
||||
Rect2i(const int rx, const int ry, const int rw, const int rh);
|
||||
Rect2i(const Vector2i &position, const Vector2i &size);
|
||||
Rect2i(const Vector2 &position, const Vector2 &size);
|
||||
Rect2i(const Vector2i &position, const Vector2 &size);
|
||||
Rect2i(const Vector2 &position, const Vector2i &size);
|
||||
|
||||
int x;
|
||||
int y;
|
||||
|
Loading…
Reference in New Issue
Block a user