Program Listing for File point.cpp¶
↰ Return to documentation for file (src/core/point.cpp
)
/*
* Point.cpp - Defines a point on a grid.
* Also used to define the size of a grid.
*/
#include "point.h"
namespace PixelMaestro {
Point::Point(uint16_t x, uint16_t y) {
set(x, y);
}
Point::Point(const Point &other) {
set(other.x, other.y);
}
uint32_t Point::get_inline_index(uint16_t x, uint16_t y) const {
return (y * this->x) + x;
}
bool Point::in_bounds(uint16_t x, uint16_t y) const {
return (x < this->x && y < this->y);
}
void Point::set(uint16_t x, uint16_t y) {
this->x = x;
this->y = y;
}
uint32_t Point::size() const {
return x * y;
}
}