pashapm / svg-android-2

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

Added Q,q and T,t path commands #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am working on reading in some svg fonts and neede the Qq and Tt commands so 
I've implemented them. 
My first tests show some pretty good results.

Just add these after case A,a and before the default case in doPath in 
SVGParser.

case 'T':
case 't': {
    wasCurve = true;
    float x = ph.nextFloat();
    float y = ph.nextFloat();
    if (cmd == 't') {
        x += lastX;
        y += lastY;
    }
    float x1 = 2 * lastX - lastX1;
    float y1 = 2 * lastY - lastY1;
    p.cubicTo( lastX, lastY, x1, y1, x, y );
    lastX = x;
    lastY = y;
    lastX1 = x1;
    lastY1 = y1;
    break;
}
case 'Q':
case 'q': {
    wasCurve = true;
    float x1 = ph.nextFloat();
    float y1 = ph.nextFloat();
    float x = ph.nextFloat();
    float y = ph.nextFloat();
    if (cmd == 'q') {
        x += lastX;
        y += lastY;
        x1 += lastX;
        y1 += lastY;
    }
    p.cubicTo( lastX, lastY, x1, y1, x, y );
    lastX1 = x1;
    lastY1 = y1;
    lastX = x;
    lastY = y;
    break;
}

Enjoy!

Original issue reported on code.google.com by m...@j-roen.net on 5 Jun 2012 at 11:09

GoogleCodeExporter commented 9 years ago

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