Esempio n. 1
0
 public QuadCurve2D evaluate(QuadCurve2D v0, QuadCurve2D v1, float fraction) {
   double x1 = v0.getX1() + ((v1.getX1() - v0.getX1()) * fraction);
   double y1 = v0.getY1() + ((v1.getY1() - v0.getY1()) * fraction);
   double x2 = v0.getX2() + ((v1.getX2() - v0.getX2()) * fraction);
   double y2 = v0.getY2() + ((v1.getY2() - v0.getY2()) * fraction);
   double ctrlx = v0.getCtrlX() + ((v1.getCtrlX() - v0.getCtrlX()) * fraction);
   double ctrly = v0.getCtrlY() + ((v1.getCtrlY() - v0.getCtrlY()) * fraction);
   QuadCurve2D value = (QuadCurve2D) v0.clone();
   value.setCurve(x1, y1, ctrlx, ctrly, x2, y2);
   return value;
 }
Esempio n. 2
0
 private static CubicCurve2D _toCubicCurve(Shape seg, CubicCurve2D cub) {
   if (cub == null) {
     cub = new CubicCurve2D.Double();
   }
   if (seg instanceof Line2D) {
     Line2D src = (Line2D) seg;
     cub.setCurve(
         src.getX1(),
         src.getY1(),
         src.getX1(),
         src.getY1(),
         src.getX2(),
         src.getY2(),
         src.getX2(),
         src.getY2());
   } else if (seg instanceof Ellipse2D) {
     throw new InternalError("Can't convert Ellipse2D to CubicCurve2D");
   } else if (seg instanceof Arc2D) {
     throw new InternalError("Can't convert Arc2D to CubicCurve2D");
   } else if (seg instanceof QuadCurve2D) {
     QuadCurve2D src = (QuadCurve2D) seg;
     cub.setCurve(
         src.getX1(),
         src.getY1(),
         src.getCtrlX(),
         src.getCtrlY(),
         src.getCtrlX(),
         src.getCtrlY(),
         src.getX2(),
         src.getY2());
   } else {
     CubicCurve2D src = (CubicCurve2D) seg;
     cub.setCurve(
         src.getX1(),
         src.getY1(),
         src.getCtrlX1(),
         src.getCtrlY1(),
         src.getCtrlX2(),
         src.getCtrlY2(),
         src.getX2(),
         src.getY2());
   }
   return cub;
 }