コード例 #1
0
            public int currentSegment(double[] coords)
            {
                if (isDone())
                {
                    throw new java.util.NoSuchElementException("Iterator out of bounds"); //$NON-NLS-1$
                }
                int type;
                int count;

                if (index == 0)
                {
                    type      = PathIteratorConstants.SEG_MOVETO;
                    coords[0] = c.getX1();
                    coords[1] = c.getY1();
                    count     = 1;
                }
                else
                {
                    type      = PathIteratorConstants.SEG_CUBICTO;
                    coords[0] = c.getCtrlX1();
                    coords[1] = c.getCtrlY1();
                    coords[2] = c.getCtrlX2();
                    coords[3] = c.getCtrlY2();
                    coords[4] = c.getX2();
                    coords[5] = c.getY2();
                    count     = 3;
                }
                if (t != null)
                {
                    t.transform(coords, 0, coords, 0, count);
                }
                return(type);
            }
コード例 #2
0
        public static void subdivide(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right)
        {
            double x1  = src.getX1();
            double y1  = src.getY1();
            double cx1 = src.getCtrlX1();
            double cy1 = src.getCtrlY1();
            double cx2 = src.getCtrlX2();
            double cy2 = src.getCtrlY2();
            double x2  = src.getX2();
            double y2  = src.getY2();
            double cx  = (cx1 + cx2) / 2.0;
            double cy  = (cy1 + cy2) / 2.0;

            cx1 = (x1 + cx1) / 2.0;
            cy1 = (y1 + cy1) / 2.0;
            cx2 = (x2 + cx2) / 2.0;
            cy2 = (y2 + cy2) / 2.0;
            double ax = (cx1 + cx) / 2.0;
            double ay = (cy1 + cy) / 2.0;
            double bx = (cx2 + cx) / 2.0;
            double by = (cy2 + cy) / 2.0;

            cx = (ax + bx) / 2.0;
            cy = (ay + by) / 2.0;
            if (left != null)
            {
                left.setCurve(x1, y1, cx1, cy1, ax, ay, cx, cy);
            }
            if (right != null)
            {
                right.setCurve(cx, cy, bx, by, cx2, cy2, x2, y2);
            }
        }
コード例 #3
0
 public static void subdivide(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right)
 {
     double x1 = src.getX1();
     double y1 = src.getY1();
     double cx1 = src.getCtrlX1();
     double cy1 = src.getCtrlY1();
     double cx2 = src.getCtrlX2();
     double cy2 = src.getCtrlY2();
     double x2 = src.getX2();
     double y2 = src.getY2();
     double cx = (cx1 + cx2) / 2.0;
     double cy = (cy1 + cy2) / 2.0;
     cx1 = (x1 + cx1) / 2.0;
     cy1 = (y1 + cy1) / 2.0;
     cx2 = (x2 + cx2) / 2.0;
     cy2 = (y2 + cy2) / 2.0;
     double ax = (cx1 + cx) / 2.0;
     double ay = (cy1 + cy) / 2.0;
     double bx = (cx2 + cx) / 2.0;
     double by = (cy2 + cy) / 2.0;
     cx = (ax + bx) / 2.0;
     cy = (ay + by) / 2.0;
     if (left != null) {
     left.setCurve(x1, y1, cx1, cy1, ax, ay, cx, cy);
     }
     if (right != null) {
     right.setCurve(cx, cy, bx, by, cx2, cy2, x2, y2);
     }
 }
コード例 #4
0
 public void setCurve(CubicCurve2D curve)
 {
     setCurve(
         curve.getX1(), curve.getY1(),
         curve.getCtrlX1(), curve.getCtrlY1(),
         curve.getCtrlX2(), curve.getCtrlY2(),
         curve.getX2(), curve.getY2());
 }
コード例 #5
0
 public void setCurve(CubicCurve2D curve)
 {
     setCurve(
         curve.getX1(), curve.getY1(),
         curve.getCtrlX1(), curve.getCtrlY1(),
         curve.getCtrlX2(), curve.getCtrlY2(),
         curve.getX2(), curve.getY2());
 }