blob: dd6efabc639b1858ca008923323b3a7dfc5a458e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#pragma once
#include <vector>
#include <Magnum/Magnum.h>
#include <Magnum/Math/Vector2.h>
#include <opencv2/core/mat.hpp>
struct anim_frame;
namespace std::filesystem { class path; }
struct anim_atlas_entry
{
anim_frame* frame;
cv::Mat4b mat;
};
struct anim_atlas_row
{
std::vector<anim_atlas_entry> data;
int max_height = 0, xpos = 0, ypos = 0;
void add_entry(const anim_atlas_entry& x);
};
class anim_atlas
{
std::vector<anim_atlas_row> rows = {{}};
int ypos = 0, maxx = 0;
public:
void add_entry(const anim_atlas_entry& x) { rows.back().add_entry(x); }
void advance_row();
Magnum::Vector2i offset() const;
Magnum::Vector2i size() const;
[[nodiscard]] bool dump(const std::filesystem::path& filename) const;
};
|