Skip to content

Instantly share code, notes, and snippets.

@tcw165
Last active November 4, 2018 04:52
Show Gist options
  • Select an option

  • Save tcw165/9f76a9b09bd580eec23b0564bbaaeff1 to your computer and use it in GitHub Desktop.

Select an option

Save tcw165/9f76a9b09bd580eec23b0564bbaaeff1 to your computer and use it in GitHub Desktop.
inline fun Canvas.runSafely(
lambda: Canvas.() -> Unit
) {
val checkPoint = save()
// "this" is Canvas
lambda.invoke(this)
restoreToCount(checkPoint)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment