I am able to draw a rectangle using the code below (works). However, I am using the Vison framework to detect rectangles but it is giving me back CGPoint values that is less than 1.0. When I enter these coordinates to draw a rectangle I get nothing back. Please can some advise?
Works - i get a rectangle
let rectangle = UIBezierPath.init()
rectangle.move(to: CGPoint.init(x: 100, y: 100))
rectangle.addLine(to: CGPoint.init(x: 200, y: 130))
rectangle.addLine(to: CGPoint.init(x: 300, y: 400))
rectangle.addLine(to: CGPoint.init(x: 100, y: 500))
rectangle.close()
let rec = CAShapeLayer.init()
rec.path = rectangle.cgPath
rec.fillColor = UIColor.red.cgColor
self.view.layer.addSublayer(rec)
Does not work (no rectangle):
let rectangle = UIBezierPath.init()
rectangle.move(to: CGPoint.init(x: 0.154599294066429, y: 0.904223263263702))
rectangle.addLine(to: CGPoint.init(x: 0.8810795545578, y: 0.970198452472687))
rectangle.addLine(to: CGPoint.init(x: 0.16680309176445, y: 0.0157230049371719))
rectangle.addLine(to: CGPoint.init(x: 0.878569722175598, y: 0.128135353326797))
rectangle.close()
let rec = CAShapeLayer.init()
rec.path = rectangle.cgPath
rec.fillColor = UIColor.red.cgColor
self.view.layer.addSublayer(rec)