Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell
Created April 7, 2017 22:31
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 dustinlacewell/ce12a355f21be45e8fbfde6f0bca22d0 to your computer and use it in GitHub Desktop.
Save dustinlacewell/ce12a355f21be45e8fbfde6f0bca22d0 to your computer and use it in GitHub Desktop.
type Region*[T: int|float] = object
left*, top*, right*, bottom*: T
proc width*[T](self: Region): T = self.right - self.left
proc height*[T](self: Region): T = self.bottom - self.top
proc midpointW*[T](self: Region[T], position: float): T = self.left + position * self.width[T]()
proc midpointH*[T](self: Region[T], position: float): T = self.top + position * self.height[T]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment