/// <summary> /// Returns a Bezier smoothed version of the StylusPoints /// </summary> /// <returns></returns> public StylusPointCollection GetBezierStylusPoints() { // Since we can't compute Bezier for single point stroke, we should return. if (_stylusPoints.Count < 2) { return(_stylusPoints); } // Construct the Bezier approximation Bezier bezier = new Bezier(); if (!bezier.ConstructBezierState(_stylusPoints, DrawingAttributes.FittingError)) { //construction failed, return a clone of the original points return(_stylusPoints.Clone()); } double tolerance = 0.5; StylusShape stylusShape = this.DrawingAttributes.StylusShape; if (null != stylusShape) { Rect shapeBoundingBox = stylusShape.BoundingBox; double min = Math.Min(shapeBoundingBox.Width, shapeBoundingBox.Height); tolerance = Math.Log10(min + min); tolerance *= (StrokeCollectionSerializer.AvalonToHimetricMultiplier / 2); if (tolerance < 0.5) { //don't allow tolerance to drop below .5 or we //can wind up with an huge amount of bezier points tolerance = 0.5; } } List <Point> bezierPoints = bezier.Flatten(tolerance); return(GetInterpolatedStylusPoints(bezierPoints)); }