fillRectGradient

fun Canvas.fillRectGradient(x: Int, y: Int, width: Int, height: Int, col1: Color, col2: Color, vertical: Boolean = true)

Draws a filled rectangle with a gradient on the canvas.

Parameters

x

The X coordinate of the rectangle top-left corner

y

The Y coordinate of the rectangle top-left corner

width

The width of the rectangle

height

The height of the rectangle

col1

The first color of the gradient

col2

The second color of the gradient

vertical

Whether the gradient is vertical (true) or horizontal (false)


fun Canvas.fillRectGradient(x: Int, y: Int, width: Int, height: Int, topLeft: Color, bottomLeft: Color, topRight: Color, bottomRight: Color)

Draws a filled rectangle with a four-corner gradient on the canvas.

Parameters

x

The X coordinate of the rectangle top-left corner

y

The Y coordinate of the rectangle top-left corner

width

The width of the rectangle

height

The height of the rectangle

topLeft

The color of the top-left corner

bottomLeft

The color of the bottom-left corner

topRight

The color of the top-right corner

bottomRight

The color of the bottom-right corner