diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-22 03:56:58 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-22 03:56:58 +0100 |
| commit | 9e749583791c9523efab90665ffd8f5c30e4f449 (patch) | |
| tree | bcb7fd1774e0b1ca4f69ff19c9c2f9e3c63eac1a /src/tile-atlas.cpp | |
| parent | 34c451c6b64ba1c11efa9a390c16e2097a25279a (diff) | |
a wip
Diffstat (limited to 'src/tile-atlas.cpp')
| -rw-r--r-- | src/tile-atlas.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/tile-atlas.cpp b/src/tile-atlas.cpp index b16de6e8..1596247f 100644 --- a/src/tile-atlas.cpp +++ b/src/tile-atlas.cpp @@ -1,5 +1,5 @@ - #include "tile-atlas.hpp" +#include "quads.hpp" #include "compat/assert.hpp" #include "tile-image.hpp" #include "compat/exception.hpp" @@ -10,6 +10,8 @@ namespace floormat { +using namespace floormat::Quads; + tile_atlas::tile_atlas(StringView path, StringView name, const ImageView2D& image, Vector2ub tile_count, Optional<enum pass_mode> p) : texcoords_{make_texcoords_array(Vector2ui(image.size()), tile_count)}, path_{path}, name_{name}, size_{image.size()}, dims_{tile_count}, passability{std::move(p)} @@ -34,19 +36,6 @@ std::array<Vector2, 4> tile_atlas::texcoords_for_id(size_t i) const return texcoords_[i]; } -auto tile_atlas::texcoords_at(Vector2ui pos_, Vector2ui size_, Vector2ui image_size_) -> texcoords -{ - auto pos = Vector2(pos_), size = Vector2(size_), image_size = Vector2(image_size_); - auto offset = pos + Vector2(.5f), end = offset + size - Vector2(1); - auto x0 = offset / image_size, x1 = end / image_size; - return {{ - { x1.x(), 1.f - x1.y() }, // bottom right - { x1.x(), 1.f - x0.y() }, // top right - { x0.x(), 1.f - x1.y() }, // bottom left - { x0.x(), 1.f - x0.y() }, // top left - }}; -} - auto tile_atlas::make_texcoords(Vector2ui pixel_size, Vector2ub tile_count, size_t i) -> texcoords { const auto sz = pixel_size/Vector2ui{tile_count}; |
