diff options
Diffstat (limited to '')
| -rw-r--r-- | src/livarot/PathCutting.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 201f64b54..49b2c5a78 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -58,31 +58,36 @@ void Path::DashPolyline(float head,float tail,float body,int nbD,float *dashs,b void Path::DashPolylineFromStyle(SPStyle *style, float scale, float min_len) { - if (style->stroke_dash.n_dash) { + if (!style->stroke_dasharray.values.empty()) { double dlen = 0.0; - for (int i = 0; i < style->stroke_dash.n_dash; i++) { - dlen += style->stroke_dash.dash[i] * scale; + // Find total length + for (unsigned i = 0; i < style->stroke_dasharray.values.size(); i++) { + dlen += style->stroke_dasharray.values[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; + // Extract out dash pattern (relative positions) + double dash_offset = style->stroke_dashoffset.value * scale; + size_t n_dash = style->stroke_dasharray.values.size(); + double *dash = g_new(double, n_dash); + for (unsigned i = 0; i < n_dash; i++) { + dash[i] = style->stroke_dasharray.values[i] * scale; } - int nbD=dash.n_dash; + + // Convert relative positions to absolute postions + int nbD = n_dash; float *dashs=(float*)malloc((nbD+1)*sizeof(float)); - while ( dash.offset >= dlen ) dash.offset-=dlen; - dashs[0]=dash.dash[0]; + while ( dash_offset >= dlen ) dash_offset-=dlen; + dashs[0]=dash[0]; for (int i=1; i<nbD; i++) { - dashs[i]=dashs[i-1]+dash.dash[i]; + dashs[i]=dashs[i-1]+dash[i]; } + // modulo dlen - this->DashPolyline(0.0, 0.0, dlen, nbD, dashs, true, dash.offset); + this->DashPolyline(0.0, 0.0, dlen, nbD, dashs, true, dash_offset); + free(dashs); - g_free(dash.dash); + g_free(dash); } } } @@ -641,21 +646,21 @@ Path** Path::SubPathsWithNesting(int &outNb,bool killNoSurf,int nbNest,int* } curAdd=NULL; } - Path* hasDad=NULL; + Path* hasParent=NULL; for (int j=0;j<nbNest;j++) { if ( conts[j] == i && nesting[j] >= 0 ) { - int dadMvt=conts[nesting[j]]; + int parentMvt=conts[nesting[j]]; for (int k=0;k<nbRes;k++) { - if ( res[k] && res[k]->descr_cmd.empty() == false && res[k]->descr_cmd[0]->associated == dadMvt ) { - hasDad=res[k]; + if ( res[k] && res[k]->descr_cmd.empty() == false && res[k]->descr_cmd[0]->associated == parentMvt ) { + hasParent=res[k]; break; } } } if ( conts[j] > i ) break; } - if ( hasDad ) { - curAdd=hasDad; + if ( hasParent ) { + curAdd=hasParent; increment=true; } else { curAdd=new Path; |
