![]() |
Wang Tiling
A Simple Wang Tiling Generator
|
Wang tiler. More...
#include <WangTiler.h>
Public Member Functions | |
| CWangTiler (size_t w, size_t h) | |
| Constructor. More... | |
| ~CWangTiler () | |
| Destructor. More... | |
| void | Generate () |
| Generate tiling. More... | |
| const size_t | GetWidth () const |
| Get width in tiles. More... | |
| const size_t | GetHeight () const |
| Get height in tiles. More... | |
| const size_t | operator() (size_t i, size_t j) const |
| Get tile index. More... | |
Private Member Functions | |
| UINT | Match (UINT x, UINT y) |
| Choose random tile. More... | |
Private Attributes | |
| UINT ** | m_nTile = nullptr |
| Array of tile indices. More... | |
| size_t | m_nWidth = 0 |
| Array width in tiles. More... | |
| size_t | m_nHeight = 0 |
| Array height in tiles. More... | |
| std::default_random_engine | m_stdRandom |
| Pseudo-random number generator. More... | |
The Wang tiler generates a pseudo-random rectangular array of tile indices into a set of 8 Wang tiles that seamlessly tile the plane.
Definition at line 37 of file WangTiler.h.
| CWangTiler::CWangTiler | ( | size_t | w, |
| size_t | h | ||
| ) |
Set the pseudo-random number generator seed to timeGetTime(), the number of milliseconds since Windows last rebooted. This should be sufficiently unpredictable to make a good seed. Allocate memory for the tile array m_nTile.
| w | Width in tiles. |
| h | Height in tiles. |
Definition at line 37 of file WangTiler.cpp.
| CWangTiler::~CWangTiler | ( | ) |
Deallocate memory from the tile array m_nTile.
Definition at line 52 of file WangTiler.cpp.
| void CWangTiler::Generate | ( | ) |
Generate a Wang tiling of width m_nWidth and height m_nHeight into m_nTile using m_stdRandom as a source of randomness.
Definition at line 72 of file WangTiler.cpp.
| const size_t CWangTiler::GetHeight | ( | ) | const |
| const size_t CWangTiler::GetWidth | ( | ) | const |
|
private |
Get a pseudo-random tile that matches tiles above and to the left.
| x | Index of the tile to the left. |
| y | Index of the tile above. |
Definition at line 64 of file WangTiler.cpp.
| const size_t CWangTiler::operator() | ( | size_t | i, |
| size_t | j | ||
| ) | const |
Get tile index from m_nTile.
| i | Row number. |
| j | Column number. |
m_nTile[i][j]. Definition at line 93 of file WangTiler.cpp.
|
private |
Definition at line 42 of file WangTiler.h.
|
private |
Definition at line 39 of file WangTiler.h.
|
private |
Definition at line 41 of file WangTiler.h.
|
private |
Definition at line 44 of file WangTiler.h.