Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Curves seem a bit jagged #85

Open
robertmiles3 opened this issue Jul 26, 2017 · 5 comments
Open

Curves seem a bit jagged #85

robertmiles3 opened this issue Jul 26, 2017 · 5 comments

Comments

@robertmiles3
Copy link

robertmiles3 commented Jul 26, 2017

Just finding this and checking it out (great work by the way!!). I love that it's a component and could easily be what I'm looking for.

I'm comparing a few Xamarin samples of drawing like SpeedSketch and TouchCanvas. I've noticed that the curves as you write on SignaturePad are slightly jagged and not as smooth as some of these samples. Is there anything I can help with to get it a bit smoother? So far, SpeedSketch is by far the smoothest lines and curves I've seen among the samples. After reviewing the code, I'm finding it incredibly hard to follow, but I'd be willing to dig if pointed in the right direction.

Here's a side-by-side example of me writing an "R" with my Apple Pencil on both SignaturePad and SpeedSketch (iPad Pro 2017 10.5"):
screen shot 2017-07-26 at 7 36 48 pm

@robertmiles3
Copy link
Author

I think I've made a little progress with just a few lines of code. Instead of using the SmoothedPathWithGranularity function, I made some tweaks to the iOS InkPresenter and came up with this.

screen shot 2017-07-28 at 10 32 50 am

Besides looking better, the stats reported from the sample app show the old at 200-250 points while my new shows 50-60 points.

@mattleibow
Copy link
Contributor

Hi @robertmiles3, that looks good. What did you do?

@robertmiles3
Copy link
Author

You can check it at...

https://github.com/robertmiles3/SignaturePad/tree/smoother-paths

For now, it's working great. I've only edited the iOS portion so far, so if it's liked then we can figure out the other platforms as well.

@mattleibow
Copy link
Contributor

mattleibow commented Aug 30, 2017

@robertmiles3 This looks really good. I tested it out and it works pretty well.

The only thing that I noticed is that the last point is sometimes "lost". You are waiting for 4 points, but the user may stop before.

For Android, this extension method may help:

public static void AddCurveToPoint (this Path path, System.Drawing.PointF endPoint, System.Drawing.PointF controlPoint1, System.Drawing.PointF controlPoint2)
{
    path.CubicTo (controlPoint1.X, controlPoint1.Y, controlPoint2.X, controlPoint2.Y, endPoint.X, endPoint.Y);
}

Other than that one issue with the last point, I think this is something that I would like to merge it as soon as you are finished.

@mattleibow
Copy link
Contributor

Just linking this: #92

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants