43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
/// @file
|
|
/// @brief Task2: SVG-Line element https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "task2.Element.hpp"
|
|
#include "task2.aliases.hpp"
|
|
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
namespace task2 {
|
|
|
|
/// @brief Line SVG Element
|
|
/// open: <line fill='none' stroke='black' stroke-width='1' x1='{{a[0]}}' y1='{{a[1]}}' x2='{{b[0]}}' y2='{{b[1]}}' '/>
|
|
/// text: empty string
|
|
/// close: empty string
|
|
struct LineElement : Element {
|
|
LineElement(Line line) : line(line) { }
|
|
std::string open() const override final {
|
|
auto [a, b] = line;
|
|
std::stringstream ss;
|
|
ss << "<line ";
|
|
ss << "stroke-width='1' ";
|
|
ss << "fill='none' ";
|
|
ss << "stroke='black' ";
|
|
ss << "x1='" << a[0] << "' ";
|
|
ss << "y1='" << a[1] << "' ";
|
|
ss << "x2='" << b[0] << "' ";
|
|
ss << "y2='" << b[1] << "' ";
|
|
ss << " />";
|
|
return ss.str();
|
|
}
|
|
std::string close() const override final { return std::string(); }
|
|
std::string text() const override final { return std::string(); }
|
|
|
|
private:
|
|
Line line;
|
|
};
|
|
|
|
} // namespace task2
|