Area
Area is a type used to delimit a specific zone, notably for defining camera bounds, physics world limits, and tile regions.
Overview
Area is represented by the type Area, included in the header "remake2d/area.hpp". It is composed of four integers:
i32 x: coordinate on the X axisi32 y: coordinate on the Y axisi32 w: area's widthi32 h: area's height
Info
Unlike Vec2d and Dim2d, Area takes integer values rather than floats because it uses whole pixels for coordinates and size, not relative values. The Area type is also comparable (compare size only).
Method
The Area type own three methods:
Vec2d pos(void) const noexcept; // get Area upper-left position
Dim2d size(void) const noexcept; // get Area size
Vec2d center(void) const noexcept; // get Area center
Usage
Its constructors is as follows:
#include <remake2d/area.hpp>
int main(void) {
rmk::Area zone = { 400, 300, 100, 100 }; // Area at coordinates (400, 300) with size (100, 100)
}
Arithmetic
Area also supports the following operators: +, -, /, *, %, +=, -=, /=, *=, and %=:
#include <remake2d/math.hpp>
int main(void) {
rmk::Area z1 = { 100, 200, 300, 400 };
rmk::Area z2 = { 50, 100, 100, 200 };
rmk::Area z3 = z1 + z2; // { 150, 300, 400, 600 }
rmk::Area z4 = z1 - z2; // { 50, 100, 200, 200 }
rmk::Area z5 = z1 * z2; // { 5000, 20000, 30000, 80000 }
rmk::Area z6 = z1 % z2; // { 0, 0, 0, 0 }
}
Property
| Type | Copiable | Movable | Bases and Traits |
|---|---|---|---|
| Area | Yes | Yes | Printable |