You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

92 lines
2.6 KiB

/**
* @file automap_render.cpp
*
* Line drawing routines for the automap.
*/
#include "engine/render/automap_render.hpp"
namespace devilution {
namespace {
enum class DirectionX {
EAST = 1,
WEST = -1,
};
enum class DirectionY {
SOUTH = 1,
NORTH = -1,
};
template <DirectionX DirX, DirectionY DirY>
void DrawMapLine(const Surface &out, Point from, int height, std::uint8_t colorIndex)
{
while (height-- > 0) {
out.SetPixel({ from.x, from.y + 1 }, 0);
out.SetPixel(from, colorIndex);
from.x += static_cast<int>(DirX);
out.SetPixel({ from.x, from.y + 1 }, 0);
out.SetPixel(from, colorIndex);
from.x += static_cast<int>(DirX);
from.y += static_cast<int>(DirY);
}
out.SetPixel({ from.x, from.y + 1 }, 0);
out.SetPixel(from, colorIndex);
}
template <DirectionX DirX, DirectionY DirY>
void DrawMapLineSteep(const Surface &out, Point from, int width, std::uint8_t colorIndex)
{
while (width-- > 0) {
out.SetPixel(from, colorIndex);
from.y += static_cast<int>(DirY);
out.SetPixel(from, colorIndex);
from.y += static_cast<int>(DirY);
from.x += static_cast<int>(DirX);
}
out.SetPixel(from, colorIndex);
}
} // namespace
void DrawMapLineNE(const Surface &out, Point from, int height, std::uint8_t colorIndex)
{
DrawMapLine<DirectionX::EAST, DirectionY::NORTH>(out, from, height, colorIndex);
}
void DrawMapLineSE(const Surface &out, Point from, int height, std::uint8_t colorIndex)
{
DrawMapLine<DirectionX::EAST, DirectionY::SOUTH>(out, from, height, colorIndex);
}
void DrawMapLineNW(const Surface &out, Point from, int height, std::uint8_t colorIndex)
{
DrawMapLine<DirectionX::WEST, DirectionY::NORTH>(out, from, height, colorIndex);
}
void DrawMapLineSW(const Surface &out, Point from, int height, std::uint8_t colorIndex)
{
DrawMapLine<DirectionX::WEST, DirectionY::SOUTH>(out, from, height, colorIndex);
}
void DrawMapLineSteepNE(const Surface &out, Point from, int width, std::uint8_t colorIndex)
{
DrawMapLineSteep<DirectionX::EAST, DirectionY::NORTH>(out, from, width, colorIndex);
}
void DrawMapLineSteepSE(const Surface &out, Point from, int width, std::uint8_t colorIndex)
{
DrawMapLineSteep<DirectionX::EAST, DirectionY::SOUTH>(out, from, width, colorIndex);
}
void DrawMapLineSteepNW(const Surface &out, Point from, int width, std::uint8_t colorIndex)
{
DrawMapLineSteep<DirectionX::WEST, DirectionY::NORTH>(out, from, width, colorIndex);
}
void DrawMapLineSteepSW(const Surface &out, Point from, int width, std::uint8_t colorIndex)
{
DrawMapLineSteep<DirectionX::WEST, DirectionY::SOUTH>(out, from, width, colorIndex);
}
} // namespace devilution