24 lines
623 B
C++
24 lines
623 B
C++
|
#include "linesfml.h"
|
||
|
|
||
|
LineSFML::LineSFML(const std::shared_ptr<sf::RenderTarget>& render_target) :
|
||
|
_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);
|
||
|
}
|