hlfw.ca

binpack

ref: 6e43aa4d46695de7c4d281e0b776c65e0d38c2d9
dir: /binpack.h/

View raw version
#include <stdbool.h>

#define MAX_BIN 64

struct Input {
	unsigned minw;
	unsigned minh;
	unsigned maxw;
	unsigned maxh;
	unsigned wid;
};

struct Output {
	unsigned w;
	unsigned h;
	unsigned x;
	unsigned y;
	unsigned wid;
};

struct Current {
	unsigned w;
	unsigned h;
	unsigned wid;
};

void binary_bin_pack(unsigned width, unsigned height, struct Output out[], struct Input in[]);
bool bin_pack(unsigned width, unsigned height, struct Current c[], struct Output out[], unsigned count);
void split(struct Input *in, struct Input *a, struct Input *b, size_t length);
void center(unsigned width, unsigned height, struct Output out[], unsigned gaps);
void sort_bins(struct Input r[], const size_t length);
void print_bin(struct Output out[], size_t length);
void offset(struct Output out[], unsigned w);
size_t init_bins(struct Input r[]);
struct Input pop(struct Input in[]);
void push(struct Input in[], struct Input temp);