question: public static GeneralPath stackSpline ( GeneralPath p , float pts [ ] , int start , int npoints , float epsilon , float slack , boolean closed , float tx , float ty ) { int len = 2 * npoints ; int end = start + len ; if ( len < 6 ) { throw new IllegalArgumentException ( "To create spline requires at least 3 points" ) ; } float dx1 , dy1 , dx2 , dy2 ; if ( closed ) { dx2 = pts [ start + 2 ] - pts [ end - 2 ] ; dy2 = pts [ start + 3 ] - pts [ end - 1 ] ; } else { dx2 = pts [ start + 4 ] - pts [ start ] ; dy2 = pts [ start + 5 ] - pts [ start + 1 ] ; } int i ; for ( i = start + 2 ; i < end - 2 ; i += 2 ) { dx1 = dx2 ; dy1 = dy2 ; dx2 = pts [ i + 2 ] - pts [ i - 2 ] ; dy2 = pts [ i + 3 ] - pts [ i - 1 ] ; if ( Math . abs ( pts [ i ] - pts [ i - 2 ] ) < epsilon || Math . abs ( pts [ i + 1 ] - pts [ i - 1 ] ) < epsilon ) { p . lineTo ( tx + pts [ i ] , ty + pts [ i + 1 ] ) ; } else { p . curveTo ( tx + pts [ i - 2 ] + slack * dx1 , ty + pts [ i - 1 ] + slack * dy1 , tx + pts [ i ] - slack * dx2 , ty + pts [ i + 1 ] - slack * dy2 , tx + pts [ i ] , ty + pts [ i + 1 ] ) ; } } dx1 = dx2 ; dy1 = dy2 ; dx2 = pts [ start ] - pts [ i - 2 ] ; dy2 = pts [ start + 1 ] - pts [ i - 1 ] ; if ( Math . abs ( pts [ i ] - pts [ i - 2 ] ) < epsilon || Math . abs ( pts [ i + 1 ] - pts [ i - 1 ] ) < epsilon ) { p . lineTo ( tx + pts [ i ] , ty + pts [ i + 1 ] ) ; } else { p . curveTo ( tx + pts [ i - 2 ] + slack * dx1 , ty + pts [ i - 1 ] + slack * dy1 , tx + pts [ i ] - slack * dx2 , ty + pts [ i + 1 ] - slack * dy2 , tx + pts [ i ] , ty + pts [ i + 1 ] ) ; } if ( closed ) { if ( Math . abs ( pts [ end - 2 ] - pts [ 0 ] ) < epsilon || Math . abs ( pts [ end - 1 ] - pts [ 1 ] ) < epsilon ) { p . lineTo ( tx + pts [ 0 ] , ty + pts [ 1 ] ) ; } else { dx1 = dx2 ; dy1 = dy2 ; dx2 = pts [ start + 2 ] - pts [ end - 2 ] ; dy2 = pts [ start + 3 ] - pts [ end - 1 ] ; p . curveTo ( tx + pts [ end - 2 ] + slack * dx1 , ty + pts [ end - 1 ] + slack * dy1 , tx + pts [ 0 ] - slack * dx2 , ty + pts [ 1 ] - slack * dy2 , tx + pts [ 0 ] , ty + pts [ 1 ] ) ; } p . closePath ( ) ; } return p ; }
target:  Computes a set of curves using the cardinal spline approach, but using straight lines for completely horizontal or vertical segments.