Skip to content

Commit 4c98466

Browse files
committed
Fix issue #1761
1 parent 87f1e21 commit 4c98466

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

core/src/processing/opengl/LinePath.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void needRoom(boolean needMove, int newPoints) {
195195
floatCoords = copyOf(floatCoords, size + grow);
196196
}
197197
size = pointColors.length;
198-
if (numCoords + newPoints > size) {
198+
if (numCoords/2 + newPoints > size) {
199199
int grow = size;
200200
if (grow > EXPAND_MAX) {
201201
grow = EXPAND_MAX;
@@ -225,7 +225,7 @@ public final void moveTo(float x, float y, int c) {
225225
if (numTypes > 0 && pointTypes[numTypes - 1] == SEG_MOVETO) {
226226
floatCoords[numCoords - 2] = x;
227227
floatCoords[numCoords - 1] = y;
228-
pointColors[numCoords/2] = c;
228+
pointColors[numCoords/2-1] = c;
229229
} else {
230230
needRoom(false, 1);
231231
pointTypes[numTypes++] = SEG_MOVETO;
@@ -339,6 +339,8 @@ static public class PathIterator {
339339
PathIterator(LinePath p2df) {
340340
this.path = p2df;
341341
this.floatCoords = p2df.floatCoords;
342+
pointIdx = 0;
343+
colorIdx = 0;
342344
}
343345

344346
public int currentSegment(float[] coords) {
@@ -381,8 +383,10 @@ public boolean isDone() {
381383

382384
public void next() {
383385
int type = path.pointTypes[typeIdx++];
384-
pointIdx += curvecoords[type];
385-
colorIdx++;
386+
if (0 < curvecoords[type]) {
387+
pointIdx += curvecoords[type];
388+
colorIdx++;
389+
}
386390
}
387391
}
388392

0 commit comments

Comments
 (0)