Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
curve.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
14#ifndef SEEN_DISPLAY_CURVE_H
15#define SEEN_DISPLAY_CURVE_H
16
17#include <cstddef>
18#include <optional>
19#include <2geom/pathvector.h>
20
22bool is_closed(Geom::PathVector const &pathv);
23
29size_t node_count(Geom::PathVector const &pathv);
30
36Geom::Curve const *get_last_segment(Geom::Path const &) = delete;
37
43Geom::Curve const *get_first_segment(Geom::Path const &) = delete;
44
46void stretch_endpoints(Geom::PathVector &pathv, Geom::Point const &new_p0, Geom::Point const &new_p1);
47
49void move_endpoints(Geom::PathVector &pathv, Geom::Point const &new_p0, Geom::Point const &new_p1);
50void move_endpoints(Geom::Path &pathv, Geom::Point const &new_p0, Geom::Point const &new_p1);
51
54
60void pathvector_append(Geom::PathVector &to, Geom::PathVector const &pathv, bool use_lineto = false);
61
70bool pathvector_append_continuous(Geom::PathVector &to, Geom::PathVector const &pathv, double tolerance = 0.0625);
71
77
83
85void backspace(Geom::PathVector &pathv);
86void backspace(Geom::Path &path);
87
89template <typename T>
90auto ptr_to_opt(T const &p)
91{
92 return p ? std::make_optional(*p) : std::nullopt;
93}
94
96Geom::Path path_from_curve(std::unique_ptr<Geom::Curve> curve);
98
99#endif // SEEN_DISPLAY_CURVE_H
100
101/*
102 Local Variables:
103 mode:c++
104 c-file-style:"stroustrup"
105 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
106 indent-tabs-mode:nil
107 fill-column:99
108 End:
109*/
110// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
Abstract continuous curve on a plane defined on [0,1].
Definition curve.h:78
Sequence of subpaths.
Definition pathvector.h:122
Sequence of contiguous curves, aka spline.
Definition path.h:353
Two-dimensional point that doubles as a vector.
Definition point.h:66
Axis aligned, non-empty rectangle.
Definition rect.h:92
void pathvector_append(Geom::PathVector &to, Geom::PathVector const &pathv, bool use_lineto=false)
Append pathv to to.
Definition curve.cpp:78
void backspace(Geom::PathVector &pathv)
Remove last segment of curve.
Definition curve.cpp:139
size_t node_count(Geom::PathVector const &pathv)
returns the number of nodes in a path, used for statusbar text when selecting an spcurve.
Definition curve.cpp:201
void move_endpoints(Geom::PathVector &pathv, Geom::Point const &new_p0, Geom::Point const &new_p1)
Sets start of first path to new_p0, and end of first path to new_p1.
Definition curve.cpp:188
Geom::Curve const * get_last_segment(Geom::PathVector const &pathv)
Return last pathsegment (possibly the closing path segment) of the last path in PathVector or null.
Definition curve.cpp:62
bool pathvector_append_continuous(Geom::PathVector &to, Geom::PathVector const &pathv, double tolerance=0.0625)
Append pathv to to with possible fusing of close endpoints.
Definition curve.cpp:104
void stretch_endpoints(Geom::PathVector &pathv, Geom::Point const &new_p0, Geom::Point const &new_p1)
?
Definition curve.cpp:164
Geom::Path path_from_curve(std::unique_ptr< Geom::Curve > curve)
Construct an open Geom::Path from Geom::Curve. Fixme: Should be in 2geom.
Definition curve.cpp:244
Geom::Path rect_to_open_path(Geom::Rect const &rect)
Construct an open path from a rectangle.
Definition curve.cpp:22
auto ptr_to_opt(T const &p)
Create a std::optional<T> from a (generalised) pointer to T.
Definition curve.h:90
Geom::Curve const * get_first_segment(Geom::PathVector const &pathv)
Return first pathsegment in PathVector or NULL.
Definition curve.cpp:70
void closepath_current(Geom::Path &path)
Close path by setting the end point to the start point instead of adding a new lineto.
Definition curve.cpp:37
void last_point_additive_move(Geom::PathVector &pathv, Geom::Point const &p)
Add p to the last point (and last handle if present) of the last path.
Definition curve.cpp:227
bool is_closed(Geom::PathVector const &pathv)
Whether all subpaths are closed. Returns false if the curve is empty.
Definition curve.cpp:47
PathVector - a sequence of subpaths.
Definition curve.h:24