Skip to content

Instantly share code, notes, and snippets.

@codePrincess
Created August 3, 2017 14:37
Show Gist options
  • Save codePrincess/2a637737a41db63ea79de67dc71442f8 to your computer and use it in GitHub Desktop.
Save codePrincess/2a637737a41db63ea79de67dc71442f8 to your computer and use it in GitHub Desktop.
draw rectangle over current drawing area
func drawDoodlingRect(context: CGContext?) {
let inset = 5
markerColor.setStroke()
context!.setLineWidth(1.0)
context!.setLineCap(.round)
UIColor.clear.setFill()
ocrImageRect = CGRect(x: minX - inset, y: minY - inset, width: (maxX-minX) + inset*2, height: (maxY-minY) + 2*inset)
context!.addRect(ocrImageRect!)
context!.strokePath()
drawTextRect(context: context, rect: ocrImageRect!)
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
fetchOCRText()
resetDoodleRect()
}
func drawTextRect(context: CGContext?, rect: CGRect) {
UIColor.lightGray.setStroke()
currentTextRect = CGRect(x: rect.origin.x, y: rect.origin.y + rect.height, width: rect.width, height: 15)
context!.addRect(currentTextRect!)
context!.strokePath()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment