mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
wg_engine: handle properly odd numbers of dashes/gaps
If the provided list has an odd number of values, then it should be repeated to yield an even number of values. @Issue: https://github.com/thorvg/thorvg/issues/3205
This commit is contained in:
parent
391777091c
commit
ddcbbf771f
1 changed files with 5 additions and 4 deletions
|
@ -309,10 +309,10 @@ struct WgVertexBufferInd
|
||||||
}
|
}
|
||||||
len_total -= dashOffset;
|
len_total -= dashOffset;
|
||||||
// iterate by polyline points
|
// iterate by polyline points
|
||||||
|
auto gap = false;
|
||||||
for (uint32_t i = 0; i < buff.vcount - 1; i++) {
|
for (uint32_t i = 0; i < buff.vcount - 1; i++) {
|
||||||
// append current polyline point
|
// append current polyline point
|
||||||
if (index_dash % 2 == 0)
|
if (!gap) dashed.append(buff.vbuff[i]);
|
||||||
dashed.append(buff.vbuff[i]);
|
|
||||||
// move inside polyline segment
|
// move inside polyline segment
|
||||||
while(len_total < buff.vdist[i+1]) {
|
while(len_total < buff.vdist[i+1]) {
|
||||||
// get current point
|
// get current point
|
||||||
|
@ -321,17 +321,18 @@ struct WgVertexBufferInd
|
||||||
index_dash = (index_dash + 1) % dashCnt;
|
index_dash = (index_dash + 1) % dashCnt;
|
||||||
len_total += dashPattern[index_dash];
|
len_total += dashPattern[index_dash];
|
||||||
// preceed stroke if dash
|
// preceed stroke if dash
|
||||||
if (index_dash % 2 != 0) {
|
if (!gap) {
|
||||||
dashed.updateDistances();
|
dashed.updateDistances();
|
||||||
appendStrokes(dashed, rstroke);
|
appendStrokes(dashed, rstroke);
|
||||||
dashed.reset(tscale);
|
dashed.reset(tscale);
|
||||||
}
|
}
|
||||||
|
gap = !gap;
|
||||||
}
|
}
|
||||||
// update current subline length
|
// update current subline length
|
||||||
len_total -= buff.vdist[i+1];
|
len_total -= buff.vdist[i+1];
|
||||||
}
|
}
|
||||||
// draw last subline
|
// draw last subline
|
||||||
if (index_dash % 2 == 0) {
|
if (!gap) {
|
||||||
dashed.append(buff.last());
|
dashed.append(buff.last());
|
||||||
dashed.updateDistances();
|
dashed.updateDistances();
|
||||||
appendStrokes(dashed, rstroke);
|
appendStrokes(dashed, rstroke);
|
||||||
|
|
Loading…
Add table
Reference in a new issue