omeshwar / svg-android-2

Automatically exported from code.google.com/p/svg-android-2
Apache License 2.0
0 stars 0 forks source link

Paths not closed properly #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Attempt to view attached number8.svg file.

What is the expected output? What do you see instead?
Expect to see a regular number 8 displayed.  Last two paths of figure 8 are 
closed wrongly causing a cross over on lower loop.

What version of the product are you using? On what operating system?
svgAndroid2.12Dec2011.jar (with additional patches - see other issues by me).
Android 2.3.3 Emulated.

Please provide any additional information below.
Need to track initial coord of contour so that lastX and lastY can be updated 
when contour is closed.
Need to manually close because android.graphics.path will curve the closure 
whereas SVG expects a straight line.

Patch:

Add variables to track initial contour coord:

        float contourInitialX = 0;
        float contourInitialY = 0;

Update these whenever a new contour is started by a 'm' command:

            case 'M':
            case 'm': {
                float x = ph.nextFloat();
                float y = ph.nextFloat();
                if (cmd == 'm') {
                    p.rMoveTo(x, y);
                    lastX += x;
                    lastY += y;
                } else {
                    p.moveTo(x, y);
                    lastX = x;
                    lastY = y;
                }
                contourInitialX = lastX;
                contourInitialY = lastY;
                break;
            }

Close the path manually and update lastX and lastY:

            case 'Z':
            case 'z': {
                p.lineTo(contourInitialX, contourInitialY);
                p.close();
                lastX = contourInitialX;
                lastY = contourInitialY;
                break;
            }

Original issue reported on code.google.com by t...@vokware.com on 18 Apr 2012 at 4:29

Attachments:

GoogleCodeExporter commented 8 years ago
fixed

Original comment by suh...@google.com on 30 Sep 2013 at 4:21

GoogleCodeExporter commented 8 years ago

Original comment by suh...@google.com on 7 Nov 2013 at 3:52