49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
/// @file
|
|
/// @brief Task2: SVG-Polyline element https://developer.mozilla.org/en-US/docs/Web/SVG/Element/polyline
|
|
|
|
#pragma once
|
|
|
|
#include "task2.Element.hpp"
|
|
#include "task2.aliases.hpp"
|
|
|
|
/// @todo Include standard library headers as needed
|
|
#include <string>
|
|
|
|
namespace task2 {
|
|
|
|
/// @brief Polyline SVG Element
|
|
/// @todo Implement the constructor from a task2::Polyline
|
|
/// @todo Implement the class to return the fowllowing strings on the interface functions:
|
|
/// open: <polyline fill='none' stroke='black' stroke-width='1' points=' x1,y1 x2,y2, x3,y3 ... '/>
|
|
/// text: empty string
|
|
/// close: empty string
|
|
/// @note You can use/add member variables to the class as you see fit
|
|
struct PolylineElement : Element {
|
|
Polyline polyline;
|
|
|
|
PolylineElement(Polyline polyline) {
|
|
this->polyline = polyline;
|
|
}
|
|
std::string open() const override final {
|
|
std::stringstream ss;
|
|
ss << "<polyline ";
|
|
ss << "stroke-width='1' ";
|
|
ss << "fill='none' ";
|
|
ss << "stroke='black' ";
|
|
ss << "points='";
|
|
for (auto& point : polyline) {
|
|
ss << point[0] << "," << point[1] << " ";
|
|
}
|
|
ss << "' />";
|
|
return ss.str();
|
|
}
|
|
std::string close() const override final {
|
|
return std::string();
|
|
}
|
|
std::string text() const override final {
|
|
return std::string();
|
|
}
|
|
};
|
|
|
|
} // namespace task2
|