// returing curve for BC segment // all coords are vectors against Bpoint protected static String lastSegmentToCurve(int[][] stroke, float lineCurveThreshold) throws Exception { // Here we tidy up things left unfinished // What's left unfinished there is the curve between the last points // in the stroke // We can also be called when there is only one point in the stroke (meaning, the // stroke was just a dot), in which case there is nothing for us to do. // So for "this curve" to be calc'ed we need 3 points // A, B, C // and 2 lines: // pre-line (from points A to B), // this line (from points B to C) // Well, actually, we don't need to *know* the point A, just the vector A->B // so, we really need points B, C and AB vector. int positionInStroke = stroke.length - 1; // there must be at least 2 points in the stroke.for us to work. Hope calling code checks for // that. Vector BCvector = new Vector(stroke[positionInStroke][0], stroke[positionInStroke][1]); /* [UNSUPPORTED] 'var' as type is unsupported "var" */ rounding = 2; String curvetemplate = "c {0} {1} {2} {3} {4} {5}"; String linetemplate = "l {0} {1}"; if (positionInStroke > 1 && BCvector.getLength() > lineCurveThreshold) { // we have at least 3 elems in stroke Vector ABvector = new Vector(stroke[positionInStroke - 1][0], stroke[positionInStroke - 1][1]); /* [UNSUPPORTED] 'var' as type is unsupported "var" */ ABCangle = BCvector.angleTo(ABvector.getReversed()); /* [UNSUPPORTED] 'var' as type is unsupported "var" */ minlenfraction = 0.05; /* [UNSUPPORTED] 'var' as type is unsupported "var" */ maxlen = BCvector.getLength() * 0.35; Vector BtoCP1vector = new Vector(ABvector.x + BCvector.x, ABvector.y + BCvector.y) .getResizedTo((float) (Math.Max(minlenfraction, ABCangle) * maxlen)); return String.Format( curvetemplate, Math.Round(BtoCP1vector.x, rounding), Math.Round(BtoCP1vector.y, rounding), Math.Round(BCvector.x, rounding), Math.Round(BCvector.y, rounding), Math.Round(BCvector.x, rounding), Math.Round(BCvector.y, rounding)); } else { return String.Format( linetemplate, Math.Round(BCvector.x, rounding), Math.Round(BCvector.y, rounding)); } }