minetestmapper/include/PixelAttributes.h

45 lines
745 B
C
Raw Permalink Normal View History

#pragma once
2012-08-25 13:19:58 +02:00
#include <climits>
#include <cstdint>
2022-02-09 22:46:07 +01:00
#define BLOCK_SIZE 16
2012-08-25 13:19:58 +02:00
struct PixelAttribute {
2022-02-09 22:46:07 +01:00
PixelAttribute() : height(INT16_MIN), thickness(0) {};
int16_t height;
uint8_t thickness;
2022-02-09 22:46:07 +01:00
inline bool valid_height() const {
return height != INT16_MIN;
2012-08-25 13:27:40 +02:00
}
2012-08-25 13:19:58 +02:00
};
class PixelAttributes
{
public:
PixelAttributes();
2012-09-01 14:36:14 +02:00
virtual ~PixelAttributes();
2022-02-09 22:46:07 +01:00
2012-08-25 13:19:58 +02:00
void setWidth(int width);
void scroll();
2022-02-09 22:46:07 +01:00
inline PixelAttribute &attribute(int z, int x) {
return m_pixelAttributes[z + 1][x + 1];
};
2012-08-25 13:19:58 +02:00
private:
2012-09-01 14:36:14 +02:00
void freeAttributes();
private:
enum Line {
FirstLine = 0,
LastLine = BLOCK_SIZE,
EmptyLine = BLOCK_SIZE + 1,
2012-09-01 16:17:58 +02:00
LineCount = BLOCK_SIZE + 2
2012-09-01 14:36:14 +02:00
};
PixelAttribute *m_pixelAttributes[BLOCK_SIZE + 2]; // 1px gradient + empty
int m_width;
2012-08-25 13:19:58 +02:00
};