core-ktx / androidx.graphics / android.graphics.Picture / record

record

inline fun Picture.record(width: Int, height: Int, block: Canvas.() -> Unit): Picture

Creates a new Canvas to record commands in this Picture, executes the specified block on the newly created canvas and returns this Picture. Example:

return myPicture.record(1280, 720) {
   drawLine(…)
   translate(…)
   drawRect(…)
}