diff options
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/curve.cpp | 17 | ||||
| -rw-r--r-- | src/display/curve.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 9e571fdd0..04af56990 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -124,6 +124,23 @@ SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]) return curve; } +SPCurve *sp_curve_new_from_rect(NR::Maybe<NR::Rect> const &rect) +{ + g_return_val_if_fail(rect, NULL); + + SPCurve *c = sp_curve_new(); + + NR::Point p = rect->corner(0); + sp_curve_moveto(c, p); + + for (int i=3; i>=0; i--) { + sp_curve_lineto(c, rect->corner(i)); + } + sp_curve_closepath_current(c); + + return c; +} + /** * Increase refcount of curve. * diff --git a/src/display/curve.h b/src/display/curve.h index 5be8f5a4e..847d09f46 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -19,6 +19,7 @@ #include "libnr/nr-forward.h" #include "libnr/nr-point.h" +#include "libnr/nr-rect.h" /// Wrapper around NArtBpath. struct SPCurve { @@ -70,6 +71,7 @@ SPCurve *sp_curve_new(); SPCurve *sp_curve_new_sized(gint length); SPCurve *sp_curve_new_from_bpath(NArtBpath *bpath); SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]); +SPCurve *sp_curve_new_from_rect(NR::Maybe<NR::Rect> const &rect); SPCurve *sp_curve_ref(SPCurve *curve); SPCurve *sp_curve_unref(SPCurve *curve); |
