draw.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <planet/sdl/draw.hpp>


void planet::sdl::draw_hex(
        renderer &renderer,
        ui::panel &space,
        hexmap::coordinates const loc,
        float const radius) {
    auto const vertices = loc.vertices(1.0f, radius);
    std::array<SDL_Point, 7> drawing{};
    for (std::size_t index{}; auto v : vertices) {
        auto const p = space.into(v);
        drawing[index++] = {int(p.x()), int(p.y())};
    }
    drawing[6] = drawing[0];
    renderer.lines(drawing);
}