minetestmapper/PixelAttributes.h

51 lines
1.1 KiB
C
Raw Normal View History

2012-08-25 13:19:58 +02:00
/*
* =====================================================================
* Version: 1.0
* Created: 25.08.2012 10:55:29
* Author: Miroslav Bendík
* Company: LinuxOS.sk
* =====================================================================
*/
#ifndef PIXELATTRIBUTES_H_ADZ35GYF
#define PIXELATTRIBUTES_H_ADZ35GYF
2012-08-25 13:27:40 +02:00
#include <limits>
#include <stdint.h>
2012-09-01 14:36:14 +02:00
#include "config.h"
2012-08-25 13:19:58 +02:00
struct PixelAttribute {
PixelAttribute(): height(std::numeric_limits<int>::min()), thicken(0) {};
2012-08-25 13:19:58 +02:00
int height;
uint8_t thicken;
2012-08-25 13:27:40 +02:00
inline bool valid_height() {
return height != std::numeric_limits<int>::min();
}
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();
2012-09-01 14:36:14 +02: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
};
#endif /* end of include guard: PIXELATTRIBUTES_H_ADZ35GYF */