use of com.xenoage.zong.symbols.path.LineTo in project Zong by Xenoage.
the class AwtPath method createShape.
public static Shape createShape(Path path) {
GeneralPath shape = new GeneralPath();
for (PathElement e : path.getElements()) {
switch(e.getType()) {
case ClosePath:
shape.closePath();
break;
case CubicCurveTo:
CubicCurveTo c = (CubicCurveTo) e;
shape.curveTo(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;
shape.lineTo(l.p.x, l.p.y);
break;
case MoveTo:
MoveTo m = (MoveTo) e;
shape.moveTo(m.p.x, m.p.y);
break;
case QuadraticCurveTo:
QuadraticCurveTo q = (QuadraticCurveTo) e;
shape.quadTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
break;
}
}
return shape;
}
use of com.xenoage.zong.symbols.path.LineTo in project Zong by Xenoage.
the class JfxPath method drawPath.
public static void drawPath(Path path, GraphicsContext context) {
context.beginPath();
for (PathElement e : path.getElements()) {
switch(e.getType()) {
case ClosePath:
context.closePath();
break;
case CubicCurveTo:
CubicCurveTo c = (CubicCurveTo) e;
context.bezierCurveTo(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;
context.lineTo(l.p.x, l.p.y);
break;
case MoveTo:
MoveTo m = (MoveTo) e;
context.moveTo(m.p.x, m.p.y);
break;
case QuadraticCurveTo:
QuadraticCurveTo q = (QuadraticCurveTo) e;
context.quadraticCurveTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
break;
}
}
}
use of com.xenoage.zong.symbols.path.LineTo in project Zong by Xenoage.
the class SvgPathReaderTest method testImplicitLineToAbs.
@Test
public void testImplicitLineToAbs() {
String validPath = "M1200,1300 1400,1050 1600,1300 1800,1550 2000,1300z";
Path p = new SvgPathReader(validPath).read();
assertEquals(alist(new MoveTo(p(2, 3)), new LineTo(p(4, 0.5f)), new LineTo(p(6, 3)), new LineTo(p(8, 5.5f)), new LineTo(p(10, 3)), new ClosePath()), p.getElements());
}
use of com.xenoage.zong.symbols.path.LineTo in project Zong by Xenoage.
the class SvgPathReaderTest method test2.
@Test
public void test2() {
String validPath = "M1200,1300 L1400,1050 L1600,1300 1800,1550 M2000,1300z";
Path p = new SvgPathReader(validPath).read();
assertEquals(alist(new MoveTo(p(2, 3)), new LineTo(p(4, 0.5f)), new LineTo(p(6, 3)), new LineTo(p(8, 5.5f)), new MoveTo(p(10, 3)), new ClosePath()), p.getElements());
}
use of com.xenoage.zong.symbols.path.LineTo in project Zong by Xenoage.
the class SvgPathReaderTest method test1.
@Test
public void test1() {
String validPath = "M 1100 1100 L 1300 1100 L 1200 1300 z";
Path p = new SvgPathReader(validPath).read();
assertEquals(alist(new MoveTo(p(1, 1)), new LineTo(p(3, 1)), new LineTo(p(2, 3)), new ClosePath()), p.getElements());
}
Aggregations