use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class TestParsingPSbezier method testParse9Coordinates.
@Test
public void testParse9Coordinates() {
parser("\\psbezier(1,2)(3,4)(5,6)(7,8)(9,10)(11,12)(13,14)(15,16)(17,18)");
final BezierCurve bc = getShapeAt(0);
assertEquals(4, bc.getNbPoints());
assertEquals(0d, bc.getPtAt(0).getX(), 0.0001);
assertEquals(0d, bc.getPtAt(0).getY(), 0.0001);
assertEquals(5d * Shape.PPC, bc.getPtAt(1).getX(), 0.0001);
assertEquals(-6d * Shape.PPC, bc.getPtAt(1).getY(), 0.0001);
assertEquals(11d * Shape.PPC, bc.getPtAt(2).getX(), 0.0001);
assertEquals(-12d * Shape.PPC, bc.getPtAt(2).getY(), 0.0001);
assertEquals(17d * Shape.PPC, bc.getPtAt(3).getX(), 0.0001);
assertEquals(-18d * Shape.PPC, bc.getPtAt(3).getY(), 0.0001);
assertEquals(-1d * Shape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
assertEquals(2d * Shape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
assertEquals(7d * Shape.PPC, bc.getSecondCtrlPtAt(1).getX(), 0.0001);
assertEquals(-8d * Shape.PPC, bc.getSecondCtrlPtAt(1).getY(), 0.0001);
assertEquals(13d * Shape.PPC, bc.getSecondCtrlPtAt(2).getX(), 0.0001);
assertEquals(-14d * Shape.PPC, bc.getSecondCtrlPtAt(2).getY(), 0.0001);
assertEquals(3d * Shape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
assertEquals(-4d * Shape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
assertEquals(9d * Shape.PPC, bc.getFirstCtrlPtAt(2).getX(), 0.0001);
assertEquals(-10d * Shape.PPC, bc.getFirstCtrlPtAt(2).getY(), 0.0001);
assertEquals(15d * Shape.PPC, bc.getFirstCtrlPtAt(3).getX(), 0.0001);
assertEquals(-16d * Shape.PPC, bc.getFirstCtrlPtAt(3).getY(), 0.0001);
}
use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class TestParsingPSbezier method testParse4Coordinates.
@Test
public void testParse4Coordinates() {
parser("\\psbezier(5,10)(1,2)(3,4)(5,6)");
final BezierCurve bc = getShapeAt(0);
assertEquals(2, bc.getNbPoints());
assertEquals(5d * Shape.PPC, bc.getPtAt(0).getX(), 0.0001);
assertEquals(-10d * Shape.PPC, bc.getPtAt(0).getY(), 0.0001);
assertEquals(5d * Shape.PPC, bc.getPtAt(1).getX(), 0.0001);
assertEquals(-6d * Shape.PPC, bc.getPtAt(1).getY(), 0.0001);
assertEquals(9d * Shape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
assertEquals(-18d * Shape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
assertEquals(3d * Shape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
assertEquals(-4d * Shape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
}
use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class TestParsingPSbezier method testParse3Coordinates.
@Test
public void testParse3Coordinates() {
parser("\\psbezier(1,2)(3,4)(5,6)");
final BezierCurve bc = getShapeAt(0);
assertEquals(2, bc.getNbPoints());
assertEquals(0d, bc.getPtAt(0).getX(), 0.0001);
assertEquals(0d, bc.getPtAt(0).getY(), 0.0001);
assertEquals(5d * Shape.PPC, bc.getPtAt(1).getX(), 0.0001);
assertEquals(-6d * Shape.PPC, bc.getPtAt(1).getY(), 0.0001);
assertEquals(-1d * Shape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
assertEquals(2d * Shape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
assertEquals(3d * Shape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
assertEquals(-4d * Shape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
}
use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class TestBezierCurve method testConstructors2.
@Test
public void testConstructors2() {
final BezierCurve curve = ShapeFactory.INST.createBezierCurve(Arrays.asList(ShapeFactory.INST.createPoint(100, 200), ShapeFactory.INST.createPoint(300, 400)));
assertEquals(2, curve.getPoints().size());
assertEqualsDouble(100., curve.getPoints().get(0).getX());
assertEqualsDouble(200., curve.getPoints().get(0).getY());
assertEqualsDouble(300., curve.getPoints().get(1).getX());
assertEqualsDouble(400., curve.getPoints().get(1).getY());
assertEquals(2, curve.getFirstCtrlPts().size());
assertEquals(2, curve.getSecondCtrlPts().size());
assertEquals(2, curve.getNbArrows());
}
use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class TestShapeFactory method testCreateBezierCurveFromSameNewPoint.
@Test
void testCreateBezierCurveFromSameNewPoint() {
BezierCurve bc = ShapeFactory.INST.createBezierCurve(Collections.singletonList(ShapeFactory.INST.createPoint()));
bc = ShapeFactory.INST.createBezierCurveFrom(bc, ShapeFactory.INST.createPoint(1d, 2d));
assertEqualsDouble(1d, bc.getPtAt(1).getX());
assertEqualsDouble(2d, bc.getPtAt(1).getY());
}
Aggregations