minetestmapper/include/PixelAttributes.h

40 lines
731 B
C
Raw Normal View History

#pragma once
2012-08-25 13:19:58 +02:00
#include <climits>
#include <cstdint>
2012-09-01 14:36:14 +02:00
#include "config.h"
2012-08-25 13:19:58 +02:00
struct PixelAttribute {
PixelAttribute(): height(INT16_MIN), thickness(0) {};
int16_t height;
uint8_t thickness;
2012-08-25 13:27:40 +02:00
inline bool valid_height() {
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();
2012-08-25 13:19:58 +02:00
void setWidth(int width);
void scroll();
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
};