src/main/java/de/javagl/geom/Shapes.java
/**
     * Create a shape that is created from interpolating between the 
     * given shapes, according to the given interpolation value
     * 
     * @param shape0 The first shape
     * @param shape1 The second shape
     * @param alpha The interpolation value, usually between 0.0 and 1.0
     * @return The interpolated shape
     * @throws IllegalArgumentException If the given shapes do not consist
     * of the same segments (that is, when they are not structurally equal)
     */
Create a shape that is created from interpolating between the
given shapes, according to the given interpolation value


Create a shape that is created from interpolating between the given shapes according to the given interpolation value
public static Shape interpolate(Shape shape0, Shape shape1, double alpha)
    {
        Path2D path = new Path2D.Double();
        PathIterator pi0 = shape0.getPathIterator(null);
        PathIterator pi1 = shape1.getPathIterator(null);
        double coords0[] = new double[6];
        double coords1[] = new double[6];
        double coords[] = new double[6];
        while (!pi0.isDone())
        {
            if (pi1.isDone())
            {
                throw new IllegalArgumentException(
                    "Iterator 1 is done, but not iterator 0");
            }
            int segment0 = pi0.currentSegment(coords0);
            int segment1 = pi1.currentSegment(coords1);
            if (segment0 != segment1)
            {
                throw new IllegalArgumentException(
                    "Incompatible segments: "+segment0+" vs. "+segment1);
            }
            switch (segment0)
            {
                case PathIterator.SEG_MOVETO:
                    interpolate(coords0, coords1, coords, alpha, 2);
                    path.moveTo(coords[0], coords[1]);
                    break;
                case PathIterator.SEG_LINETO:
                    interpolate(coords0, coords1, coords, alpha, 2);
                    path.lineTo(coords[0], coords[1]);
                    break;
                case PathIterator.SEG_QUADTO:
                    interpolate(coords0, coords1, coords, alpha, 4);
                    path.quadTo(coords[0], coords[1], coords[2], coords[3]);
                    break;
                case PathIterator.SEG_CUBICTO:
                    interpolate(coords0, coords1, coords, alpha, 6);
                    path.curveTo(
                        coords[0], coords[1], 
                        coords[2], coords[3], 
                        coords[4], coords[5]);
                    break;
                case PathIterator.SEG_CLOSE:
                    path.closePath();
                    break;
                default:
                    throw new AssertionError("Unknown segment type");
            }
            pi0.next();
            pi1.next();
        }
        if (!pi1.isDone())
        {
            throw new IllegalArgumentException(
                "Iterator 0 is done, but not iterator 1");
        }
        return path;
    }
public static Shape interpolate ( Shape shape0 , Shape shape1 , double alpha ) { Path2D path = new Path2D . Double ( ) ; PathIterator pi0 = shape0 . getPathIterator ( null ) ; PathIterator pi1 = shape1 . getPathIterator ( null ) ; double coords0 [ ] = new double [ 6 ] ; double coords1 [ ] = new double [ 6 ] ; double coords [ ] = new double [ 6 ] ; while ( ! pi0 . isDone ( ) ) { if ( pi1 . isDone ( ) ) { throw new IllegalArgumentException ( "Iterator 1 is done, but not iterator 0" ) ; } int segment0 = pi0 . currentSegment ( coords0 ) ; int segment1 = pi1 . currentSegment ( coords1 ) ; if ( segment0 != segment1 ) { throw new IllegalArgumentException ( "Incompatible segments: " + segment0 + " vs. " + segment1 ) ; } switch ( segment0 ) { case PathIterator . SEG_MOVETO : interpolate ( coords0 , coords1 , coords , alpha , 2 ) ; path . moveTo ( coords [ 0 ] , coords [ 1 ] ) ; break ; case PathIterator . SEG_LINETO : interpolate ( coords0 , coords1 , coords , alpha , 2 ) ; path . lineTo ( coords [ 0 ] , coords [ 1 ] ) ; break ; case PathIterator . SEG_QUADTO : interpolate ( coords0 , coords1 , coords , alpha , 4 ) ; path . quadTo ( coords [ 0 ] , coords [ 1 ] , coords [ 2 ] , coords [ 3 ] ) ; break ; case PathIterator . SEG_CUBICTO : interpolate ( coords0 , coords1 , coords , alpha , 6 ) ; path . curveTo ( coords [ 0 ] , coords [ 1 ] , coords [ 2 ] , coords [ 3 ] , coords [ 4 ] , coords [ 5 ] ) ; break ; case PathIterator . SEG_CLOSE : path . closePath ( ) ; break ; default : throw new AssertionError ( "Unknown segment type" ) ; } pi0 . next ( ) ; pi1 . next ( ) ; } if ( ! pi1 . isDone ( ) ) { throw new IllegalArgumentException ( "Iterator 0 is done, but not iterator 1" ) ; } return path ; }
Create a shape that is created from interpolating between the
 given shapes, according to the given interpolation value
Create a shape that is created from interpolating between the given shapes according to the given interpolation value