summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 031c927)
raw | patch | inline | side by side (parent: 031c927)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Wed, 25 Jul 2007 12:12:23 +0000 (12:12 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Wed, 25 Jul 2007 12:12:23 +0000 (12:12 +0000) |
src/display/curve.cpp | patch | blob | history | |
src/display/curve.h | patch | blob | history | |
src/sp-image.cpp | patch | blob | history |
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 9e571fdd0518305801b71b09c8a85f71ebd33919..04af56990269176edf27ee68e54bc80ac3b2a2f5 100644 (file)
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
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 5be8f5a4e48497157556b898acfc9489cca97e34..847d09f46628df9b483374b7126018c284a1285a 100644 (file)
--- a/src/display/curve.h
+++ b/src/display/curve.h
#include "libnr/nr-forward.h"
#include "libnr/nr-point.h"
+#include "libnr/nr-rect.h"
/// Wrapper around NArtBpath.
struct SPCurve {
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);
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index 9f67670504a80eb268d1a5e22ea94d9db9bae50d..d535874e93c34d8ba69d0b91bb6fa1774704474e 100644 (file)
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
#include "xml/quote.h"
#include <xml/repr.h>
+#include "libnr/nr-matrix-fns.h"
+
#include "io/sys.h"
#include <png.h>
#if ENABLE_LCMS
return;
}
- SPCurve *c = sp_curve_new();
-
- double const x = image->x.computed;
- double const y = image->y.computed;
- double const w = image->width.computed;
- double const h = image->height.computed;
-
- sp_curve_moveto(c, x, y);
- sp_curve_lineto(c, x + w, y);
- sp_curve_lineto(c, x + w, y + h);
- sp_curve_lineto(c, x, y + h);
- sp_curve_lineto(c, x, y);
-
- sp_curve_closepath_current(c);
-
+ NRRect rect;
+ sp_image_bbox(image, &rect, NR::identity(), 0);
+ NR::Maybe<NR::Rect> rect2 = rect.upgrade();
+ SPCurve *c = sp_curve_new_from_rect(rect2);
+
if (image->curve) {
image->curve = sp_curve_unref(image->curve);
}
image->curve = sp_curve_ref(c);
}
- sp_curve_unref(c);
-
+ sp_curve_unref(c);
}
/**