44 bbox = CloneAs<Rect>(*other.bbox);
49 points = other.points;
51 bbox = CloneAs<Rect>(*other.bbox);
68 _(
"Wrong XML element."));
76 const auto pts =
String(t.GetValue()).Split(U
" \n\r\t");
77 for (
size_t tmp = 0; tmp < pts.size() / 2; ++tmp)
91 for (
const auto &p : points)
126 auto p = points.back();
129 p = str.points.front();
132 for (
size_t tmp = 1; tmp < str.points.size(); tmp++)
160 "const Stroke &str, double step): ") +
163 auto p = points.back();
166 p = str.points.front();
170 if (
Abs(ex - bx) >
int(step))
172 double yoffset = (ey - by) /
Abs(ex - bx);
173 double y = by + yoffset;
176 for (
int x = bx - step; x > ex; x -= step)
184 for (
int x = bx + step; x < ex; x += step)
192 for (
const auto &p : str.points)
210 if (index >= points.size())
212 _(
"index out of range."));
213 return points[index];
227 if (index >= points.size())
229 _(
"index out of range."));
230 return points[index];
244 for (
const auto &p : points)
248 _(
"Cannot reach abscissa."));
259 if (points.size() > 0)
265 auto fp = points.front();
266 Rect r(fp.X, fp.Y, fp.X, fp.Y);
267 for (
size_t tmp = 1; tmp < points.size(); tmp++)
269 const auto &p = points[tmp];
270 r |=
Rect(p.X, p.Y, p.X, p.Y);
272 bbox = CloneAs<Rect>(r);
289 for (
const auto &p : points)
309 auto filling =
false;
310 for (
const auto &p : points)
327 Cloner::Register<Stroke>();
Rect GetBBox() const
Returns the bounding box using integer values.
Stroke & operator=(const Stroke &other)
StringUTF8 GetName() const
Gets the label of the element.
Stroke MakeIntersection(const Rect &rect) const
Creates a new stroke that is the intersection of the stroke with a rectangle.
void AddPoint(const Point2DInt &p)
Adds a point to the stroke.
Stroke()
Default constructor.
Stroke MakeFirstIntersection(const Rect &rect) const
Creates a new stroke that is the first intersection of the stroke with a rectangle.
void MergeAtEnd(const Stroke &str)
Adds a batch of points directly at the end of the stroke.
void MergeWithXInterpolation(const Stroke &str, unsigned int step=1)
Adds a batch of points at their original position and adds points to interpolate. ...
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
A UTF32 character string class.
Point2DInt & GetPoint(size_t index)
Returns a reference to a point.
bool Contains(int x, int y) const noexcept
Checks if the rectangle contains a point.
#define CRN_DATA_FACTORY_REGISTER(elemname, classname)
Registers a class to the data factory.
void Deserialize(xml::Element &el)
Initializes the object from an XML element.
Node GetFirstChild()
Gets the first child node.
void Abs(Image< T > &img, typename std::enable_if< std::is_arithmetic< T >::value >::type *dummy=nullptr) noexcept
Replaces each pixel by its absolute value.
double GetFirstYAtX(double x) const
Returns the ordinate of the first point with abscissa = x.
virtual ~Stroke() override
Destructor.
A character string class.
Element PushBackElement(const StringUTF8 &name)
Adds an element at the end of the children list.
xml::Element Serialize(xml::Element &parent) const
Dumps the object to an XML element.
Invalid argument error (e.g.: nullptr pointer)
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.