Search in sources :

Example 6 with LineTo

use of com.xenoage.zong.symbols.path.LineTo in project Zong by Xenoage.

the class SvgPathReaderTest method testImplicitLineToRel.

@Test
public void testImplicitLineToRel() {
    String validPath = "m1200,1300 100,100 z";
    Path p = new SvgPathReader(validPath).read();
    assertEquals(alist(new MoveTo(p(2, 3)), new LineTo(p(3, 4f)), new ClosePath()), p.getElements());
}
Also used : ClosePath(com.xenoage.zong.symbols.path.ClosePath) Path(com.xenoage.zong.symbols.path.Path) ClosePath(com.xenoage.zong.symbols.path.ClosePath) MoveTo(com.xenoage.zong.symbols.path.MoveTo) LineTo(com.xenoage.zong.symbols.path.LineTo) Test(org.junit.Test)

Example 7 with LineTo

use of com.xenoage.zong.symbols.path.LineTo in project Zong by Xenoage.

the class SvgPathReader method lineTo.

private void lineTo(Point2f p) {
    pCurrent = p;
    elements.add(new LineTo(p));
}
Also used : LineTo(com.xenoage.zong.symbols.path.LineTo)

Example 8 with LineTo

use of com.xenoage.zong.symbols.path.LineTo in project Zong by Xenoage.

the class AndroidPath method createPath.

public static Path createPath(com.xenoage.zong.symbols.path.Path path) {
    Path ret = new Path();
    for (PathElement e : path.getElements()) {
        switch(e.getType()) {
            case ClosePath:
                ret.close();
                break;
            case CubicCurveTo:
                CubicCurveTo c = (CubicCurveTo) e;
                ret.cubicTo(c.cp1.x, c.cp1.y, c.cp2.x, c.cp2.y, c.p.x, c.p.y);
                break;
            case LineTo:
                LineTo l = (LineTo) e;
                ret.lineTo(l.p.x, l.p.y);
                break;
            case MoveTo:
                MoveTo m = (MoveTo) e;
                ret.moveTo(m.p.x, m.p.y);
                break;
            case QuadraticCurveTo:
                QuadraticCurveTo q = (QuadraticCurveTo) e;
                ret.quadTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
                break;
        }
    }
    return ret;
}
Also used : Path(android.graphics.Path) PathElement(com.xenoage.zong.symbols.path.PathElement) LineTo(com.xenoage.zong.symbols.path.LineTo) MoveTo(com.xenoage.zong.symbols.path.MoveTo) CubicCurveTo(com.xenoage.zong.symbols.path.CubicCurveTo) QuadraticCurveTo(com.xenoage.zong.symbols.path.QuadraticCurveTo)

Aggregations

LineTo (com.xenoage.zong.symbols.path.LineTo)8 MoveTo (com.xenoage.zong.symbols.path.MoveTo)7 ClosePath (com.xenoage.zong.symbols.path.ClosePath)4 Path (com.xenoage.zong.symbols.path.Path)4 Test (org.junit.Test)4 CubicCurveTo (com.xenoage.zong.symbols.path.CubicCurveTo)3 PathElement (com.xenoage.zong.symbols.path.PathElement)3 QuadraticCurveTo (com.xenoage.zong.symbols.path.QuadraticCurveTo)3 Path (android.graphics.Path)1 GeneralPath (java.awt.geom.GeneralPath)1