/** * @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 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(DirX); out.SetPixel({ from.x, from.y + 1 }, 0); out.SetPixel(from, colorIndex); from.x += static_cast(DirX); from.y += static_cast(DirY); } out.SetPixel({ from.x, from.y + 1 }, 0); out.SetPixel(from, colorIndex); } template void DrawMapLineSteep(const Surface &out, Point from, int width, std::uint8_t colorIndex) { while (width-- > 0) { out.SetPixel(from, colorIndex); from.y += static_cast(DirY); out.SetPixel(from, colorIndex); from.y += static_cast(DirY); from.x += static_cast(DirX); } out.SetPixel(from, colorIndex); } } // namespace void DrawMapLineNE(const Surface &out, Point from, int height, std::uint8_t colorIndex) { DrawMapLine(out, from, height, colorIndex); } void DrawMapLineSE(const Surface &out, Point from, int height, std::uint8_t colorIndex) { DrawMapLine(out, from, height, colorIndex); } void DrawMapLineNW(const Surface &out, Point from, int height, std::uint8_t colorIndex) { DrawMapLine(out, from, height, colorIndex); } void DrawMapLineSW(const Surface &out, Point from, int height, std::uint8_t colorIndex) { DrawMapLine(out, from, height, colorIndex); } void DrawMapLineSteepNE(const Surface &out, Point from, int width, std::uint8_t colorIndex) { DrawMapLineSteep(out, from, width, colorIndex); } void DrawMapLineSteepSE(const Surface &out, Point from, int width, std::uint8_t colorIndex) { DrawMapLineSteep(out, from, width, colorIndex); } void DrawMapLineSteepNW(const Surface &out, Point from, int width, std::uint8_t colorIndex) { DrawMapLineSteep(out, from, width, colorIndex); } void DrawMapLineSteepSW(const Surface &out, Point from, int width, std::uint8_t colorIndex) { DrawMapLineSteep(out, from, width, colorIndex); } } // namespace devilution