summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a42f21)
raw | patch | inline | side by side (parent: 6a42f21)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Fri, 26 May 2006 04:48:38 +0000 (04:48 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Fri, 26 May 2006 04:48:38 +0000 (04:48 +0000) |
src/livarot/Path.h | patch | blob | history | |
src/livarot/PathCutting.cpp | patch | blob | history |
diff --git a/src/livarot/Path.h b/src/livarot/Path.h
index 291d8f1571266eb2b4da13fc379b3875d5ba481f..8d7fd0a7e92167931076d53682fd9598bc3bafbf 100644 (file)
--- a/src/livarot/Path.h
+++ b/src/livarot/Path.h
#include "libnr/nr-point.h"
#include <libnr/nr-rect-l.h>
+struct SPStyle;
+
/*
* the Path class: a structure to hold path description and their polyline approximation (not kept in sync)
* the path description is built with regular commands like MoveTo() LineTo(), etc
// dash the polyline
// the result is stored in the polyline, so you lose the original. make a copy before if needed
void DashPolyline(float head,float tail,float body,int nbD,float *dashs,bool stPlain,float stOffset);
+
+ void DashPolylineFromStyle(SPStyle *style, float scale, float min_len);
//utilitaire pour inkscape
void LoadArtBPath(void *iP,NR::Matrix const &tr,bool doTransformation);
index f21e028204e1945ee531dcf4aebdfc6771e3d10c..59de29676f21a6280e99d5410b440739b6ec4a5b 100644 (file)
*/
#include "Path.h"
+#include "style.h"
#include "livarot/path-description.h"
#include "libnr/n-art-bpath.h"
#include "libnr/nr-point-matrix-ops.h"
}
}
+void Path::DashPolylineFromStyle(SPStyle *style, float scale, float min_len)
+{
+ if (style->stroke_dash.n_dash) {
+
+ double dlen = 0.0;
+ for (int i = 0; i < style->stroke_dash.n_dash; i++) {
+ dlen += style->stroke_dash.dash[i] * scale;
+ }
+ if (dlen >= min_len) {
+ NRVpathDash dash;
+ dash.offset = style->stroke_dash.offset * scale;
+ dash.n_dash = style->stroke_dash.n_dash;
+ dash.dash = g_new(double, dash.n_dash);
+ for (int i = 0; i < dash.n_dash; i++) {
+ dash.dash[i] = style->stroke_dash.dash[i] * scale;
+ }
+ int nbD=dash.n_dash;
+ float *dashs=(float*)malloc((nbD+1)*sizeof(float));
+ while ( dash.offset >= dlen ) dash.offset-=dlen;
+ dashs[0]=dash.dash[0];
+ for (int i=1; i<nbD; i++) {
+ dashs[i]=dashs[i-1]+dash.dash[i];
+ }
+ // modulo dlen
+ this->DashPolyline(0.0, 0.0, dlen, nbD, dashs, true, dash.offset);
+ free(dashs);
+ g_free(dash.dash);
+ }
+ }
+}
void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pts, float head,float tail,float body,int nbD,float *dashs,bool stPlain,float stOffset)