android-signaturepad
android-signaturepad copied to clipboard
Algorithm doesn't render dots
Tapping on the SignaturePad to draw dots doesn't render the zero length line.
hi, is there any solution for this bug?
Is there any workaround ? or temporary solution ?
i added this snippet in addPoint function
if(mPoints.get(0).x == mPoints.get(1).x && mPoints.get(0).y == mPoints.get(1).y &&
mPoints.get(0).x == mPoints.get(2).x && mPoints.get(0).y == mPoints.get(2).y &&
mPoints.get(1).x == mPoints.get(2).x && mPoints.get(1).y == mPoints.get(2).y) {
mPoints.get(1).x = mPoints.get(1).x + mMinWidth;
mPoints.get(1).y = mPoints.get(1).y + mMaxWidth;
mPoints.get(2).x = mPoints.get(2).x + mMinWidth;
mPoints.get(2).y = mPoints.get(2).y + mMaxWidth;
}
just to make sure, I fill 3 mpoints with min and max width so if you put dot in there, it will make a litle line on that pad
this is the full addpoint function
`private void addPoint(TimedPoint newPoint) { mPoints.add(newPoint);
int pointsCount = mPoints.size();
if (pointsCount > 3) {
// check if the line from point 0 to poin 1 is in the same spot, means dot
if(mPoints.get(0).x == mPoints.get(1).x && mPoints.get(0).y == mPoints.get(1).y &&
mPoints.get(0).x == mPoints.get(2).x && mPoints.get(0).y == mPoints.get(2).y &&
mPoints.get(1).x == mPoints.get(2).x && mPoints.get(1).y == mPoints.get(2).y) {
mPoints.get(1).x = mPoints.get(1).x + mMinWidth;
mPoints.get(1).y = mPoints.get(1).y + mMaxWidth;
mPoints.get(2).x = mPoints.get(2).x + mMinWidth;
mPoints.get(2).y = mPoints.get(2).y + mMaxWidth;
}
ControlTimedPoints tmp = calculateCurveControlPoints(mPoints.get(0), mPoints.get(1), mPoints.get(2));
TimedPoint c2 = tmp.c2;
recyclePoint(tmp.c1);
tmp = calculateCurveControlPoints(mPoints.get(1), mPoints.get(2), mPoints.get(3));
TimedPoint c3 = tmp.c1;
recyclePoint(tmp.c2);
Bezier curve = mBezierCached.set(mPoints.get(1), c2, c3, mPoints.get(2));
TimedPoint startPoint = curve.startPoint;
TimedPoint endPoint = curve.endPoint;
float velocity = endPoint.velocityFrom(startPoint);
velocity = Float.isNaN(velocity) ? 0.0f : velocity;
velocity = mVelocityFilterWeight * velocity
+ (1 - mVelocityFilterWeight) * mLastVelocity;
// The new width is a function of the velocity. Higher velocities
// correspond to thinner strokes.
float newWidth = strokeWidth(velocity);
// The Bezier's width starts out as last curve's final width, and
// gradually changes to the stroke width just calculated. The new
// width calculation is based on the velocity between the Bezier's
// start and end mPoints.
addBezier(curve, mLastWidth, newWidth);
mLastVelocity = velocity;
mLastWidth = newWidth;
// Remove the first element from the list,
// so that we always have no more than 4 mPoints in mPoints array.
recyclePoint(mPoints.remove(0));
recyclePoint(c2);
recyclePoint(c3);
} else if (pointsCount == 1) {
// To reduce the initial lag make it work with 3 mPoints
// by duplicating the first point
TimedPoint firstPoint = mPoints.get(0);
mPoints.add(getNewPoint(firstPoint.x, firstPoint.y));
}
}`
hope it helped
@robinrev How do i put this into the library?
@AndreyNazarchuk please read: https://help.github.com/articles/using-pull-requests/
Any solution so far for this bug?
This works fine for me now, has it been resolved already?
There is still an issue in the latest build. A single tap on the screen with no motion doesn't create a dot. A small amount of motion is required to get a dot.
When we tap any finger on signature box area, sometimes it does not produce any dot/image but it still saves the empty signature image in the form of bitmap. I have one action to perform in my app which should meet all the requirements including the signatures. Since, there are no signatures drawn in front of the user and it still produces the signature image internally and it allows the user to perform an action by taking the empty signature ahead. Please try to resolve the problem as soon as possible.
Thanks Varun Goyal
@gcacace Please suggest me a solution for the above problem. I would be grateful to you.
@gcacace Library is perfect but please consider this bug as high priority. @robinrev It's not working for me. :( Android 7.1.1
I have implemented a function in my code that will check to see that the signature covers at least 60% of the height of the signature area, to make sure that I get a good signature as it is used in further processing. I never actually saw the problem where a dot is not shown but added as a bitmap.