Start implementing pixel conversions as classes. WiP.
This commit is contained in:
parent
5cea116b8f
commit
83963e67ea
4 changed files with 154 additions and 21 deletions
|
@ -17,6 +17,7 @@ add_library(${PROJECT_NAME}
|
|||
tylermapsource.cpp
|
||||
tiger.c
|
||||
typename.cpp
|
||||
pixelconv.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
|
|
40
src/pixelconv.cpp
Normal file
40
src/pixelconv.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "doorkeeper/components/pixelconv.hpp"
|
||||
|
||||
namespace dk {
|
||||
PixelConvDiamond::PixelConvDiamond (bool parStaggered, bool parFirstReentrant) :
|
||||
base_class(parStaggered ? MapType_IsometricStaggered : MapType_Isometric)
|
||||
{
|
||||
}
|
||||
|
||||
PixelConvDiamond::PixelConvDiamond (MapTypes parType, bool parStaggered, bool parFirstReentrant) :
|
||||
base_class(MapType_IsometricStaggered)
|
||||
{
|
||||
}
|
||||
|
||||
auto PixelConvDiamond::to_pixel (const coords& parFrom, const coords& parSize) const -> coords {
|
||||
const auto from(parFrom);
|
||||
const CoordinateScalarType xoffs = from.y() % 2;
|
||||
|
||||
return from * parSize + coords(xoffs * parSize.x() / 2, 0);
|
||||
}
|
||||
|
||||
PixelConvHalfDiamond::PixelConvHalfDiamond (bool parHalfVertically) :
|
||||
base_class(MapType_IsometricStaggered, true, true),
|
||||
m_div(parHalfVertically ? coords(1, 2) : coords(2, 1))
|
||||
{
|
||||
}
|
||||
|
||||
auto PixelConvHalfDiamond::to_pixel (const coords& parFrom, const coords& parSize) const -> coords {
|
||||
return base_class::to_pixel(parFrom, parSize / m_div);
|
||||
}
|
||||
|
||||
PixelConvHex::PixelConvHex (bool parFirstReentrant) :
|
||||
base_class(MapType_Hex)
|
||||
{
|
||||
}
|
||||
|
||||
auto PixelConvHex::to_pixel (const coords& parFrom, const coords& parSize) const -> coords {
|
||||
DK_ASSERT(false); //not implemented
|
||||
return coords(0);
|
||||
}
|
||||
} //namespace dk
|
Loading…
Add table
Add a link
Reference in a new issue