ranges done, cool stuff

This commit is contained in:
2021-12-12 12:06:31 -05:00
parent f360be0c8d
commit d5fd89e228
5 changed files with 35 additions and 26 deletions

View File

@@ -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;
}