Drawable

abstract class Drawable : Managed

Base class for objects that draw into Canvas.

The object has a generation id, which is guaranteed to be unique across all drawables. To allow for clients of the drawable that may want to cache the results, the drawable must change its generation id whenever its internal state changes such that it will draw differently.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Return the (conservative) bounds of what the drawable will draw. If the drawable can change what it draws (e.g. animation or in response to some external change), then this must return a bounds that is always valid for all possible states.

Link copied to clipboard

Return a unique value for this instance. If two calls to this return the same value, it is presumed that calling the draw() method will render the same thing as well.

Link copied to clipboard
expect open val isClosed: Boolean

Check if underlying resource is closed.

Functions

Link copied to clipboard
expect open fun close()

Free underlying native resource, peer is useless afterwards.

Link copied to clipboard
fun draw(canvas: Canvas?): Drawable
fun draw(canvas: Canvas?, matrix: Matrix33?): Drawable
fun draw(canvas: Canvas?, x: Float, y: Float): Drawable

Draws into the specified content. The drawing sequence will be balanced upon return (i.e. the saveLevel() on the canvas will match what it was when draw() was called, and the current matrix and clip settings will not be changed.

Link copied to clipboard
Link copied to clipboard

Calling this invalidates the previous generation ID, and causes a new one to be computed the next time getGenerationId() is called. Typically this is called by the object itself, in response to its internal state changing.

Link copied to clipboard
abstract fun onDraw(canvas: Canvas?)
Link copied to clipboard
abstract fun onGetBounds(): Rect
Link copied to clipboard
expect open override fun toString(): String