ranges done, cool stuff
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
//
|
||||
// Created by m on 12/11/21.
|
||||
//
|
||||
|
||||
#include "camera.hpp"
|
||||
|
||||
Rectangle Camera::get_bounds() {
|
||||
@@ -31,3 +30,16 @@ Point Camera::camera_coords_to_screen_coords(Point camera_coord) {
|
||||
auto bounds = get_bounds();
|
||||
return Point{camera_coord.x-bounds.x, camera_coord.y-bounds.y};
|
||||
}
|
||||
|
||||
ranges::any_view<Point> Camera::get_range() {
|
||||
auto bounds = get_bounds();
|
||||
int height = bounds.height;
|
||||
int width = bounds.width;
|
||||
int miny = bounds.y;
|
||||
int minx = bounds.x;
|
||||
return ranges::views::iota(miny, height) | ranges::views::transform([width, minx](int y) {
|
||||
return ranges::views::iota(minx, width) | ranges::views::transform([y](int x) {
|
||||
return Point{x,y};
|
||||
});
|
||||
}) | ranges::views::join;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user