2021-12-29 09:59:18 -05:00
|
|
|
#include "linesfml.h"
|
|
|
|
|
2022-01-12 09:09:43 -05:00
|
|
|
LineSFML::LineSFML(sf::RenderTarget * const render_target) :
|
2021-12-29 09:59:18 -05:00
|
|
|
_render_target(render_target)
|
|
|
|
{
|
|
|
|
_vertex = sf::VertexArray(sf::LinesStrip, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LineSFML::setPosition(const kku::Point& p1, const kku::Point& p2)
|
|
|
|
{
|
|
|
|
_vertex[0].position = {p1.x, p1.y};
|
|
|
|
_vertex[1].position = {p2.x, p2.y};
|
|
|
|
}
|
|
|
|
|
|
|
|
void LineSFML::setColor(const kku::Color& c1, const kku::Color& c2)
|
|
|
|
{
|
|
|
|
_vertex[0].color = sf::Color{c1.red, c1.green, c1.blue, c1.alpha};
|
|
|
|
_vertex[1].color = sf::Color{c2.red, c2.green, c2.blue, c2.alpha};
|
|
|
|
}
|
|
|
|
|
|
|
|
void LineSFML::display()
|
|
|
|
{
|
|
|
|
_render_target->draw(_vertex);
|
2022-01-12 09:09:43 -05:00
|
|
|
}
|