Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdibContractorCC/fdcc089e48025fd3f78db2e3ffd31d79 to your computer and use it in GitHub Desktop.
Save AdibContractorCC/fdcc089e48025fd3f78db2e3ffd31d79 to your computer and use it in GitHub Desktop.
Draw hats!
let rect = observation.boundingBox.denormalized(newRect: self.view.frame)
let hatWidth = rect.size.width
let hatHeight = rect.size.height
let hatX = rect.origin.x - hatWidth/4
let hatY = rect.origin.y - hatHeight
let hatRect = CGRect(x: hatX, y: hatY, width: hatWidth, height: hatHeight)
var hat : UIImageView? = nil
if faceNumber >= self.hats.count {
hat = UIImageView(frame: hatRect)
hat!.image = UIImage.init(named: "hat")
self.hats.append(hat!)
}
else {
hat = self.hats[faceNumber]
hat!.frame = hatRect
}
self.view.addSubview(hat!)
hat!.isHidden = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment