add A2 stub

This commit is contained in:
Fabien Freling 2022-02-16 13:59:14 +01:00
parent 7d2b7b9ba7
commit 38e9a97a85
3 changed files with 55 additions and 1 deletions

View file

@ -13,6 +13,7 @@
#include <raygui.h>
#pragma clang diagnostic pop
#include "a2.h"
#include "bounding_box.h"
#include "frame.h"
#include "pack.h"
@ -95,6 +96,7 @@ int main(int argc, const char* argv[]) {
const std::vector<Color> bbox_colors = {RED, GREEN, BLUE,
YELLOW, ORANGE, PURPLE};
std::vector<freling::BoundingBox> packed_bboxes;
std::vector<freling::BoundingBox> a2_bboxes;
Vector2 win_size = {800, 450};
const int padding = 5;
@ -109,6 +111,7 @@ int main(int argc, const char* argv[]) {
Image pack_img;
Texture2D pack_texture;
bool packed = false;
bool a2_processed = false;
win_size.x = std::max(win_size.x, in_offset.x + in_texture.width + padding);
win_size.y =
@ -190,7 +193,7 @@ int main(int argc, const char* argv[]) {
b_size.y},
"Pack Rects")) {
std::optional<Frame> f_packed =
pack(*in_frame, bboxes, packed_bboxes);
freling::pack(*in_frame, bboxes, packed_bboxes);
if (packed) {
UnloadTexture(pack_texture);
@ -212,6 +215,13 @@ int main(int argc, const char* argv[]) {
SetWindowSize(win_size.x, win_size.y);
}
if (GuiButton((Rectangle){padding + (padding + b_size.x) * 2, padding,
b_size.x, b_size.y},
"A2")) {
a2_bboxes = freling::A2(packed_bboxes);
a2_processed = true;
}
//
// Input image
//
@ -242,6 +252,15 @@ int main(int argc, const char* argv[]) {
draw(b, pack_offset, color);
++c;
};
if (a2_processed) {
int c = 0;
for (const auto& b : a2_bboxes) {
const auto& color = bbox_colors[c % bbox_colors.size()];
draw(b, pack_offset, color);
++c;
};
}
}
EndDrawing();