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

Weird square at end of drawing #7

Open
saiedg opened this issue May 5, 2018 · 5 comments
Open

Weird square at end of drawing #7

saiedg opened this issue May 5, 2018 · 5 comments

Comments

@saiedg
Copy link

saiedg commented May 5, 2018

Does anyone else have this issue of the end of the signature drawing partially cut off? Sometimes it happens, sometimes it doesn't. I'm having a difficult time perfectly reproducing. Hope this can be quickly fixed.

img_3309
img_3310

@erparker
Copy link

erparker commented May 7, 2018

I'm currently messing around with undo functionality and I am seeing this as well. It's weird, I'll cache the last "signatureImage" each time endContinuousLine is called (so undo just sets the current image to the previous version) But the very last point or two are always left behind. Sometimes they look like the cut off square thing you posted.

I haven't gotten to the bottom of it yet, but I have a hunch it's related. Am really curious to know what the dealio is

@erparker
Copy link

erparker commented May 7, 2018

It looks like the temporaryBezierPath is the culprit. This was added to give us the ability to single-tap the screen and produce a dot. I completely turned it off and I'm no longer getting the jagged line cap and my undo implementation works as expected. The issue is that I'm no longer getting any line cap at all, or the single dot, since the last couple points after touches end were getting drawn by temporary bezier path.

So, short hacky version, just turn off the temporary bezier path by changing the finalSignatureImage computed property to just return signatureImage instead of returning the signatureImage with the rest of the temporary path. Yeah, it's not ideal, but I haven't messed with the project enough to fix the underlying problem.

@saiedg
Copy link
Author

saiedg commented Jun 12, 2018

Hi! Thank you for getting back to me and I apologize so much for the delayed reply! I still get the box at the end and an additional hitch at the end of the animation if I comment out lines 173 174 175 and 177:
if self.bezierPathLayer.path != output.temporarySignatureBezierPath?.cgPath {
self.bezierPathLayer.path = output.temporarySignatureBezierPath?.cgPath
}
self.isEmpty = self.bezierPathLayer.path == nil && self.imageView.image == nil

Am I doing this incorrectly?

@acushway
Copy link

acushway commented Aug 2, 2018

Take a look at UIBezierPath+WeightedPoint.swift in the "line" func.

I was reading it this morning and I think the following:

path.move(to: lines.0.start)
path.addLine(to: lines.1.start)
path.addLine(to: lines.1.end)
path.addLine(to: lines.0.start)

should be changed to:

path.move(to: lines.0.start)
path.addLine(to: lines.1.start)
path.addLine(to: lines.1.end)
path.addLine(to: lines.0.end)

Note the last addLine has changed from adding to start to adding to end.

At least that's what I thought on reading it and I was thinking the bug would manifest as a triangle in the output.

@saiedg
Copy link
Author

saiedg commented Aug 2, 2018

Fixed it!! Thank you!

@rpstro02 rpstro02 mentioned this issue Jun 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants