Fix incorrect styling on svg export
export Style::NO_STYLE which was missing styles should be set on export at the SBezierLoop-level vs the SBezierLoopSet-levelpull/948/head
parent
2fcc933aa9
commit
60dca4cb79
|
@ -735,25 +735,22 @@ void VectorFileWriter::OutputLinesAndMesh(SBezierLoopSetSet *sblss, SMesh *sm) {
|
||||||
if(sblss) {
|
if(sblss) {
|
||||||
SBezierLoopSet *sbls;
|
SBezierLoopSet *sbls;
|
||||||
for(sbls = sblss->l.First(); sbls; sbls = sblss->l.NextAfter(sbls)) {
|
for(sbls = sblss->l.First(); sbls; sbls = sblss->l.NextAfter(sbls)) {
|
||||||
SBezierLoop *sbl;
|
for(SBezierLoop *sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
|
||||||
sbl = sbls->l.First();
|
b = sbl->l.First();
|
||||||
if(!sbl) continue;
|
if(!b || !Style::Exportable(b->auxA)) continue;
|
||||||
b = sbl->l.First();
|
|
||||||
if(!b || !Style::Exportable(b->auxA)) continue;
|
|
||||||
|
|
||||||
hStyle hs = { (uint32_t)b->auxA };
|
hStyle hs = { (uint32_t)b->auxA };
|
||||||
Style *stl = Style::Get(hs);
|
Style *stl = Style::Get(hs);
|
||||||
double lineWidth = Style::WidthMm(b->auxA)*s;
|
double lineWidth = Style::WidthMm(b->auxA)*s;
|
||||||
RgbaColor strokeRgb = Style::Color(hs, /*forExport=*/true);
|
RgbaColor strokeRgb = Style::Color(hs, /*forExport=*/true);
|
||||||
RgbaColor fillRgb = Style::FillColor(hs, /*forExport=*/true);
|
RgbaColor fillRgb = Style::FillColor(hs, /*forExport=*/true);
|
||||||
|
|
||||||
StartPath(strokeRgb, lineWidth, stl->filled, fillRgb, hs);
|
StartPath(strokeRgb, lineWidth, stl->filled, fillRgb, hs);
|
||||||
for(sbl = sbls->l.First(); sbl; sbl = sbls->l.NextAfter(sbl)) {
|
|
||||||
for(b = sbl->l.First(); b; b = sbl->l.NextAfter(b)) {
|
for(b = sbl->l.First(); b; b = sbl->l.NextAfter(b)) {
|
||||||
Bezier(b);
|
Bezier(b);
|
||||||
}
|
}
|
||||||
|
FinishPath(strokeRgb, lineWidth, stl->filled, fillRgb, hs);
|
||||||
}
|
}
|
||||||
FinishPath(strokeRgb, lineWidth, stl->filled, fillRgb, hs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FinishAndCloseFile();
|
FinishAndCloseFile();
|
||||||
|
|
|
@ -1083,17 +1083,16 @@ void SvgFileWriter::StartFile() {
|
||||||
double sw = max(ptMax.x - ptMin.x, ptMax.y - ptMin.y) / 1000;
|
double sw = max(ptMax.x - ptMin.x, ptMax.y - ptMin.y) / 1000;
|
||||||
fprintf(f, "stroke-width:%f;\r\n", sw);
|
fprintf(f, "stroke-width:%f;\r\n", sw);
|
||||||
fprintf(f, "}\r\n");
|
fprintf(f, "}\r\n");
|
||||||
for(auto &style : SK.style) {
|
|
||||||
Style *s = &style;
|
|
||||||
|
|
||||||
RgbaColor strokeRgb = Style::Color(s->h, /*forExport=*/true);
|
auto export_style = [&](hStyle hs) {
|
||||||
StipplePattern pattern = Style::PatternType(s->h);
|
RgbaColor strokeRgb = Style::Color(hs, /*forExport=*/true);
|
||||||
double stippleScale = Style::StippleScaleMm(s->h);
|
StipplePattern pattern = Style::PatternType(hs);
|
||||||
|
double stippleScale = Style::StippleScaleMm(hs);
|
||||||
|
|
||||||
fprintf(f, ".s%x {\r\n", s->h.v);
|
fprintf(f, ".s%x {\r\n", hs.v);
|
||||||
fprintf(f, "stroke:#%02x%02x%02x;\r\n", strokeRgb.red, strokeRgb.green, strokeRgb.blue);
|
fprintf(f, "stroke:#%02x%02x%02x;\r\n", strokeRgb.red, strokeRgb.green, strokeRgb.blue);
|
||||||
// don't know why we have to take a half of the width
|
// don't know why we have to take a half of the width
|
||||||
fprintf(f, "stroke-width:%f;\r\n", Style::WidthMm(s->h.v) / 2.0);
|
fprintf(f, "stroke-width:%f;\r\n", Style::WidthMm(hs.v) / 2.0);
|
||||||
fprintf(f, "stroke-linecap:round;\r\n");
|
fprintf(f, "stroke-linecap:round;\r\n");
|
||||||
fprintf(f, "stroke-linejoin:round;\r\n");
|
fprintf(f, "stroke-linejoin:round;\r\n");
|
||||||
std::string patternStr = MakeStipplePattern(pattern, stippleScale, ',',
|
std::string patternStr = MakeStipplePattern(pattern, stippleScale, ',',
|
||||||
|
@ -1103,6 +1102,12 @@ void SvgFileWriter::StartFile() {
|
||||||
}
|
}
|
||||||
fprintf(f, "fill:none;\r\n");
|
fprintf(f, "fill:none;\r\n");
|
||||||
fprintf(f, "}\r\n");
|
fprintf(f, "}\r\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
export_style({Style::NO_STYLE});
|
||||||
|
for(auto &style : SK.style) {
|
||||||
|
Style *s = &style;
|
||||||
|
export_style(s->h);
|
||||||
}
|
}
|
||||||
fprintf(f, "]]></style>\r\n");
|
fprintf(f, "]]></style>\r\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue