private int AddPixelsXY(float X, float Y, bool bLastPoint) { float xNew, yNew, x1, y1; int nSeg = SEGMENT3; if (mCurrStroke < 0) { return(0); } if (strokeLen < 1) { _lastPoint.X = _previousLocation.X = X; _lastPoint.Y = _previousLocation.Y = Y; WritePadAPI.recoAddPixel(mCurrStroke, X, Y); AddCurrentPoint(X, Y); strokeLen = 1; return(1); } float dx = Math.Abs(X - _lastPoint.X); float dy = Math.Abs(Y - _lastPoint.Y); if ((dx + dy) < SEGMENT_DIST_1) { _lastPoint.X = _previousLocation.X = X; _lastPoint.Y = _previousLocation.Y = Y; WritePadAPI.recoAddPixel(mCurrStroke, X, Y); AddCurrentPoint(X, Y); strokeLen++; return(1); } if ((dx + dy) < SEGMENT_DIST_2) { nSeg = SEGMENT2; } else if ((dx + dy) < SEGMENT_DIST_3) { nSeg = SEGMENT3; } else { nSeg = SEGMENT4; } int nPoints = 0; for (int i = 1; i < nSeg; i++) { x1 = _previousLocation.X + ((X - _previousLocation.X) * i) / nSeg; //the point "to look at" y1 = _previousLocation.Y + ((Y - _previousLocation.Y) * i) / nSeg; //the point "to look at" xNew = _lastPoint.X + (x1 - _lastPoint.X) / nSeg; yNew = _lastPoint.Y + (y1 - _lastPoint.Y) / nSeg; if (xNew != _lastPoint.X || yNew != _lastPoint.Y) { _lastPoint.X = xNew; _lastPoint.Y = yNew; WritePadAPI.recoAddPixel(mCurrStroke, xNew, yNew); AddCurrentPoint(xNew, yNew); strokeLen++; nPoints++; } } if (bLastPoint) { // add last point if (X != _lastPoint.X || Y != _lastPoint.Y) { _lastPoint.X = X; _lastPoint.Y = Y; WritePadAPI.recoAddPixel(mCurrStroke, X, Y); AddCurrentPoint(X, Y); strokeLen++; nPoints++; } } _previousLocation.X = X; _previousLocation.Y = Y; return(nPoints); }