File: PixelAttributes.h

package info (click to toggle)
minetestmapper 20241111-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: cpp: 2,635; python: 143; sh: 68; ansic: 30; makefile: 9
file content (44 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include <climits>
#include <cstdint>

#define BLOCK_SIZE 16

struct PixelAttribute {
	PixelAttribute() : height(INT16_MIN), thickness(0) {};

	int16_t height;
	uint8_t thickness;

	inline bool valid_height() const {
		return height != INT16_MIN;
	}
};

class PixelAttributes
{
public:
	PixelAttributes();
	virtual ~PixelAttributes();

	void setWidth(int width);
	void scroll();

	inline PixelAttribute &attribute(int z, int x) {
		return m_pixelAttributes[z + 1][x + 1];
	};

private:
	void freeAttributes();

private:
	enum Line {
		FirstLine = 0,
		LastLine = BLOCK_SIZE,
		EmptyLine = BLOCK_SIZE + 1,
		LineCount = BLOCK_SIZE + 2
	};
	PixelAttribute *m_pixelAttributes[BLOCK_SIZE + 2]; // 1px gradient + empty
	int m_width;
};