10#ifndef BITMAP_TYPE_HPP
11#define BITMAP_TYPE_HPP
20 std::vector<bool> data;
22 inline uint Index(uint x, uint y)
const {
return y * this->
w + x; }
39 this->data.resize(Index(this->
w, this->
h));
59 this->tile =
TileXY(r.left, r.top);
63 this->data.resize(Index(
w,
h));
72 this->data.resize(Index(
w,
h));
82 this->data[Index(
tile)] =
true;
92 this->data[Index(
tile)] =
false;
128 std::unique_ptr<TileIterator>
Clone()
const override
130 return std::make_unique<BitmapTileIterator>(*
this);
Represents a tile area containing containing individually set tiles.
void SetTile(TileIndex tile)
Add a tile as part of the tile area.
void ClrTile(TileIndex tile)
Clear a tile from the tile area.
bool HasTile(TileIndex tile) const
Test if a tile is part of the tile area.
void Initialize(const Rect &r)
Initialize the BitmapTileArea with the specified Rect.
void Reset()
Reset and clear the BitmapTileArea.
TileIterator & operator++() override
Move ourselves to the next tile in the rectangle on the map.
std::unique_ptr< TileIterator > Clone() const override
Allocate a new iterator that is a copy of this one.
BitmapTileIterator(const BitmapTileArea &bitmap)
Construct the iterator.
OrthogonalTileIterator(const OrthogonalTileArea &ta)
Construct the iterator.
TileIterator & operator++() override
Move ourselves to the next tile in the rectangle on the map.
TileIterator(TileIndex tile=INVALID_TILE)
Initialise the iterator starting at this tile.
#define Rect
Macro that prevents name conflicts between included headers.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static uint TileX(TileIndex tile)
Get the X component of a tile.
bool Contains(TileIndex tile) const
Does this tile area contain a tile?
uint16_t w
The width of the area.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
int Width() const
Get width of Rect.
int Height() const
Get height of Rect.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.