1

I'm getting an error in PathParser on android when I draw this vector drawable

<vector android:height="24dp" android:viewportHeight="667.0"
    android:viewportWidth="667.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillAlpha="1" android:fillColor="#f06927"
        android:pathData="M333.5,333.5m-333.5,0a333.5,333.5 0,1 1,667 0a333.5,333.5 0,1 1,-667 0"
        android:strokeAlpha="1" android:strokeColor="#00000000"
        android:strokeLineCap="butt" android:strokeLineJoin="miter" android:strokeWidth="1"/>
</vector>

and here is the error (getting it twice)

12-06 17:06:36.273 28351-28351/com.dakota.vectorpreview W/PathParser: Points are too far apart 4.000000000000001

and here is the Android source code (line 415) that evaluates 4.000000000000001

/* Compute differences and averages */
double dx = x0p - x1p;
double dy = y0p - y1p;

double dsq = dx * dx + dy * dy;
double disc = 1.0 / dsq - 1.0 / 4.0;
if (disc < 0.0) {
    Log.w(LOGTAG, "Points are too far apart " + dsq);
    float adjust = (float) (Math.sqrt(dsq) / 1.99999);
    drawArc(p, x0, y0, x1, y1, a * adjust,
        b * adjust, theta, isMoreThanHalf, isPositiveArc);
    return; /* Points are too far apart */
}

It's drawing to the screen correctly as far as I can tell. This seems like a bug more than coding error.

EDIT: I am looking for a way to solve this answer not an explanation of why it's occurring.

  • Is the code in your question from the android source, or is it yours? Which particular pair of points is producing your error? I think that when people read your question, they're assuming you're asking about a bug in your own code. A rewrite of your question will probably help to get your question reopened. – Simon MᶜKenzie Dec 07 '15 at 03:46
  • Yeah I see what you mean. I added a link to the android source code and tried to make it a bit clearer – Dakota Jay Whipple Dec 07 '15 at 03:49
  • If you've found a bug in the parser, you should probably be raising this at the project's site, not here. Your path [appears valid](http://jsfiddle.net/gfmfmy7h/), so if you' re looking for a workaround, I'd suggest just moving some of your points. I do feel (with regards to your question), that an exact example of the error (i.e. values of `x0p, x1p, y0p, and y1p`) would make your question clearer. Also, what does "points are too far apart" mean in the context of your error? What is the purpose of the subtraction from `1.0/4.0`? The code sample is too lacking in context to be understandable. – Simon MᶜKenzie Dec 07 '15 at 03:59
  • IMO this is a bit of a bug in the Android PathParser class. It is throwing a warning, when it should have a fudge factor to allow for the vagaries of FP arithmetic. Having said that, my advice would be to ignore it. It is just a warning, not an error. If it is really bothering you, try adjusting either the arc ("a") radii or the endpoints. For example, try change the two "667" values to "666.99999". – Paul LeBeau Dec 07 '15 at 12:43
  • It sounds like you are seeing issues related to floating point precision round off errors. [This](http://floating-point-gui.de/basic/) is a good introduction to the problem. – cwbowron Dec 07 '15 at 02:00

0 Answers0