Skip to content

perfectly horizontal or perfectly vertical straight-line paths are not being calculated properly. #3

@kashif-izhar

Description

@kashif-izhar

It seems perfectly horizontal or perfectly vertical straight-line paths are not being calculated properly.

For example below results in false

topLeft = CGPoint(x: 0, y: 0)
topRight = CGPoint(x: 100, y: 0)
let path = UIBezierPath()
path.move(to: topLeft)
path.addLine(to: topRight)
let lineLayer = CAShapeLayer()
lineLayer.path = path.cgPath
lineLayer.strokeColor = UIColor.orange.cgColor
lineLayer.lineWidth = 1.0
self.view.layer.addSublayer(lineLayer)

print(lineLayer.path.intersects(drawnPath))       // drawnPath is cgPath of hand drawn UIBezierPath()

but if you change to

topLeft = CGPoint(x: 0, y: 1)

then the line is not perfectly horizontal anymore and result is true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions