Package-level declarations

Properties

Link copied to clipboard

Return the alpha component of a color int. This is equivalent to calling:

@get:RequiresApi(value = 26)
val Long.alpha: Float

Return the alpha component of a color long. This is equivalent to calling:

Link copied to clipboard
val Int.blue: Int

Return the blue component of a color int. This is equivalent to calling:

@get:RequiresApi(value = 26)
val Long.blue: Float

Return the blue component of a color long. This is equivalent to calling:

Link copied to clipboard
@get:RequiresApi(value = 26)
val Long.colorSpace: ColorSpace

Returns the color space encoded in the specified color long.

Link copied to clipboard

Return the green component of a color int. This is equivalent to calling:

@get:RequiresApi(value = 26)
val Long.green: Float

Return the green component of a color long. This is equivalent to calling:

Link copied to clipboard
@get:RequiresApi(value = 26)
val Long.isSrgb: Boolean

Indicates whether the color is in the sRGB color space.

Link copied to clipboard
@get:RequiresApi(value = 26)
val Long.isWideGamut: Boolean

Indicates whether the color is in a wide-gamut color space.

Link copied to clipboard
@get:RequiresApi(value = 26)
val Int.luminance: Float

Returns the relative luminance of a color int, assuming sRGB encoding. Based on the formula for relative luminance defined in WCAG 2.0, W3C Recommendation 11 December 2008.

@get:RequiresApi(value = 26)
val Long.luminance: Float

Returns the relative luminance of a color. Based on the formula for relative luminance defined in WCAG 2.0, W3C Recommendation 11 December 2008.

Link copied to clipboard
val Int.red: Int

Return the red component of a color int. This is equivalent to calling:

@get:RequiresApi(value = 26)
val Long.red: Float

Return the red component of a color long. This is equivalent to calling:

Functions

Link copied to clipboard
infix inline fun Path.and(p: Path): Path

Returns the intersection of two paths as a new Path. If the paths do not intersect, returns an empty path.

infix inline fun Rect.and(r: Rect): Rect
infix inline fun RectF.and(r: RectF): RectF

Returns the intersection of two rectangles as a new rectangle. If the rectangles do not intersect, returns a copy of the left hand side rectangle.

infix inline fun Region.and(r: Rect): Region

Return the intersection of this region and the specified Rect as a new region.

infix inline fun Region.and(r: Region): Region

Return the intersection of this region and the specified region as a new region.

Link copied to clipboard
inline fun Bitmap.applyCanvas(block: Canvas.() -> Unit): Bitmap

Creates a new Canvas to draw on this bitmap and executes the specified block on the newly created canvas. Example:

Link copied to clipboard
@RequiresApi(value = 26)
inline operator fun Color.component1(): Float
@RequiresApi(value = 26)
inline operator fun Long.component1(): Float

Returns the first component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the first component is "red".

inline operator fun Point.component1(): Int
inline operator fun PointF.component1(): Float

Returns the x coordinate of this point.

inline operator fun Rect.component1(): Int
inline operator fun RectF.component1(): Float

Returns "left", the first component of the rectangle.

inline operator fun Int.component1(): Int

Return the alpha component of a color int. This is equivalent to calling:

Link copied to clipboard
@RequiresApi(value = 26)
inline operator fun Color.component2(): Float
@RequiresApi(value = 26)
inline operator fun Long.component2(): Float

Returns the second component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the second component is "green".

inline operator fun Point.component2(): Int
inline operator fun PointF.component2(): Float

Returns the y coordinate of this point.

inline operator fun Rect.component2(): Int
inline operator fun RectF.component2(): Float

Returns "top", the second component of the rectangle.

inline operator fun Int.component2(): Int

Return the red component of a color int. This is equivalent to calling:

Link copied to clipboard
@RequiresApi(value = 26)
inline operator fun Color.component3(): Float

Returns the third component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the third component is "blue". = * This method allows to use destructuring declarations when working with colors, for example:

inline operator fun Rect.component3(): Int
inline operator fun RectF.component3(): Float

Returns "right", the third component of the rectangle.

inline operator fun Int.component3(): Int

Return the green component of a color int. This is equivalent to calling:

@RequiresApi(value = 26)
inline operator fun Long.component3(): Float

Returns the third component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the third component is "blue".

Link copied to clipboard
@RequiresApi(value = 26)
inline operator fun Color.component4(): Float
@RequiresApi(value = 26)
inline operator fun Long.component4(): Float

Returns the fourth component of the color. For instance, when the color model of the color is android.graphics.ColorSpace.Model.RGB, the fourth component is "alpha".

inline operator fun Rect.component4(): Int
inline operator fun RectF.component4(): Float

Returns "bottom", the fourth component of the rectangle.

inline operator fun Int.component4(): Int

Return the blue component of a color int. This is equivalent to calling:

Link copied to clipboard
inline operator fun Bitmap.contains(p: Point): Boolean
inline operator fun Bitmap.contains(p: PointF): Boolean

Returns true if the specified point is inside the bitmap. A point is contained if: 0 <= x < width and 0 <= y < height. An empty bitmap never contains any point.

inline operator fun Rect.contains(p: Point): Boolean
inline operator fun RectF.contains(p: PointF): Boolean

Returns true if the specified point is inside the rectangle. The left and top are considered to be inside, while the right and bottom are not. This means that for a point to be contained: left <= x < right and top <= y < bottom. An empty rectangle never contains any point.

inline operator fun Region.contains(p: Point): Boolean

Return true if the region contains the specified Point.

Link copied to clipboard
@RequiresApi(value = 26)
infix inline fun Color.convertTo(colorSpace: ColorSpace): Color
@RequiresApi(value = 26)
infix inline fun Color.convertTo(colorSpace: ColorSpace.Named): Color

Converts the color receiver to a color in the specified color space. This is equivalent to calling:

@RequiresApi(value = 26)
infix inline fun Int.convertTo(colorSpace: ColorSpace): Long
@RequiresApi(value = 26)
infix inline fun Int.convertTo(colorSpace: ColorSpace.Named): Long

Converts the color int receiver to a color long in the specified color space. This is equivalent to calling:

@RequiresApi(value = 26)
infix inline fun Long.convertTo(colorSpace: ColorSpace): Long
@RequiresApi(value = 26)
infix inline fun Long.convertTo(colorSpace: ColorSpace.Named): Long

Converts the color long receiver to a color long in the specified color space. This is equivalent to calling:

Link copied to clipboard
inline fun createBitmap(width: Int, height: Int, config: Bitmap.Config = Bitmap.Config.ARGB_8888): Bitmap

Returns a mutable bitmap with the specified width and height. A config can be optionally specified. If not, the default config is Bitmap.Config.ARGB_8888.

@RequiresApi(value = 26)
inline fun createBitmap(width: Int, height: Int, config: Bitmap.Config = Bitmap.Config.ARGB_8888, hasAlpha: Boolean = true, colorSpace: ColorSpace = ColorSpace.get(ColorSpace.Named.SRGB)): Bitmap

Returns a mutable bitmap with the specified width and height. The config, transparency and color space can optionally be specified. They respectively default to Bitmap.Config.ARGB_8888, true and sRGB.

Link copied to clipboard
@RequiresApi(value = 28)
inline fun ImageDecoder.Source.decodeBitmap(crossinline action: ImageDecoder.(info: ImageDecoder.ImageInfo, source: ImageDecoder.Source) -> Unit): Bitmap

Create a Bitmap from a Source

Link copied to clipboard

Create a Drawable from a Source

Link copied to clipboard
inline operator fun Point.div(scalar: Float): Point
inline operator fun PointF.div(scalar: Float): PointF

Divides this point by the specified scalar value and returns the result as a new point.

Link copied to clipboard
@RequiresApi(value = 26)
fun Path.flatten(error: Float = 0.5f): Iterable<PathSegment>

Flattens (or approximate) the Path with a series of line segments.

Link copied to clipboard
inline fun Region.forEach(action: (rect: Rect) -> Unit)

Performs the given action on each rect in this region.

Link copied to clipboard
inline operator fun Bitmap.get(x: Int, y: Int): Int

Returns the value of the pixel at the specified location. The returned value is a color int in the sRGB color space.

Link copied to clipboard
operator fun Region.iterator(): Iterator<Rect>

Returns an Iterator over the rects in this region.

Link copied to clipboard
inline operator fun Path.minus(p: Path): Path

Returns the difference of two paths as a new Path.

inline operator fun Point.minus(p: Point): Point
inline operator fun PointF.minus(p: PointF): PointF

Offsets this point by the negation of the specified point and returns the result as a new point.

inline operator fun Point.minus(xy: Int): Point
inline operator fun PointF.minus(xy: Float): PointF

Offsets this point by the negation of the specified amount on both X and Y axis and returns the result as a new point.

inline operator fun Rect.minus(xy: Point): Rect
inline operator fun RectF.minus(xy: PointF): RectF

Returns a new rectangle representing this rectangle offset by the negation of the specified point.

inline operator fun Rect.minus(r: Rect): Region

Returns the difference of this rectangle and the specified rectangle as a new region.

inline operator fun Rect.minus(xy: Int): Rect
inline operator fun RectF.minus(xy: Float): RectF

Returns a new rectangle representing this rectangle offset by the negation of the specified amount on both X and Y axis.

inline operator fun RectF.minus(r: RectF): Region

Returns the difference of this rectangle and the specified rectangle as a new region. This rectangle is first converted to a Rect using RectF.toRect.

inline operator fun Region.minus(r: Rect): Region

Return the difference of this region and the specified Rect as a new region.

inline operator fun Region.minus(r: Region): Region

Return the difference of this region and the specified region as a new region.

Link copied to clipboard
inline operator fun Region.not(): Region

Returns the negation of this region as a new region.

Link copied to clipboard
infix inline fun Path.or(p: Path): Path

Returns the union of two paths as a new Path.

infix inline fun Rect.or(r: Rect): Rect
infix inline fun RectF.or(r: RectF): RectF

Returns the union of two rectangles as a new rectangle.

infix inline fun Region.or(r: Rect): Region

Return the union of this region and the specified Rect as a new region.

infix inline fun Region.or(r: Region): Region

Return the union of this region and the specified region as a new region.

Link copied to clipboard
@RequiresApi(value = 26)
operator fun Color.plus(c: Color): Color

Composites two translucent colors together. More specifically, adds two colors using the source over blending mode. The colors must not be pre-multiplied and the result is a non pre-multiplied color.

inline operator fun Path.plus(p: Path): Path

Returns the union of two paths as a new Path.

inline operator fun Point.plus(p: Point): Point
inline operator fun PointF.plus(p: PointF): PointF

Offsets this point by the specified point and returns the result as a new point.

inline operator fun Point.plus(xy: Int): Point
inline operator fun PointF.plus(xy: Float): PointF

Offsets this point by the specified amount on both X and Y axis and returns the result as a new point.

inline operator fun Rect.plus(xy: Point): Rect
inline operator fun RectF.plus(xy: PointF): RectF

Returns a new rectangle representing this rectangle offset by the specified point.

inline operator fun Rect.plus(r: Rect): Rect
inline operator fun RectF.plus(r: RectF): RectF

Performs the union of this rectangle and the specified rectangle and returns the result as a new rectangle.

inline operator fun Rect.plus(xy: Int): Rect
inline operator fun RectF.plus(xy: Float): RectF

Returns a new rectangle representing this rectangle offset by the specified amount on both X and Y axis.

inline operator fun Region.plus(r: Rect): Region

Return the union of this region and the specified Rect as a new region.

inline operator fun Region.plus(r: Region): Region

Return the union of this region and the specified region as a new region.

Link copied to clipboard
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:

Link copied to clipboard
fun rotationMatrix(degrees: Float, px: Float = 0.0f, py: Float = 0.0f): Matrix

Creates a rotation matrix, defined by a rotation angle in degrees around the pivot point located at the coordinates (px, py).

Link copied to clipboard
inline fun Bitmap.scale(width: Int, height: Int, filter: Boolean = true): Bitmap

Creates a new bitmap, scaled from this bitmap, when possible. If the specified width and height are the same as the current width and height of this bitmap, this bitmap is returned and no new bitmap is created.

Link copied to clipboard
fun scaleMatrix(sx: Float = 1.0f, sy: Float = 1.0f): Matrix

Creates a scale matrix with the scale factor sx and sy respectively on the x and y axis.

Link copied to clipboard
inline operator fun Bitmap.set(x: Int, y: Int, @ColorInt color: Int)

Writes the specified color int into the bitmap (assuming it is mutable) at the specified (x, y) coordinate. The specified color is converted from sRGB to the bitmap's color space if needed.

Link copied to clipboard
inline fun Paint.setBlendMode(blendModeCompat: BlendModeCompat?): Boolean

Convenience method to configure the BlendMode of a Paint in a backward compatible way. This method is a no-op for BlendModes that have no equivalent on older API levels

Link copied to clipboard
inline operator fun Matrix.times(m: Matrix): Matrix

Multiplies this Matrix by another matrix and returns the result as a new matrix.

inline operator fun Point.times(scalar: Float): Point
inline operator fun PointF.times(scalar: Float): PointF

Multiplies this point by the specified scalar value and returns the result as a new point.

inline operator fun Rect.times(factor: Int): Rect
inline operator fun RectF.times(factor: Float): RectF
inline operator fun RectF.times(factor: Int): RectF

Returns a new rectangle representing this rectangle's components each scaled by factor.

Link copied to clipboard
@RequiresApi(value = 26)
inline fun Int.toColor(): Color

Creates a new Color instance from a color int. The resulting color is in the sRGB color space.

@RequiresApi(value = 26)
inline fun Long.toColor(): Color

Creates a new Color instance from a color long.

Link copied to clipboard

Creates a new PorterDuffColorFilter that uses this PorterDuff.Mode as the alpha compositing or blending mode, and the specified color.

Link copied to clipboard
@RequiresApi(value = 26)
inline fun Long.toColorInt(): Int

Converts the specified color long to an ARGB color int.

Return a corresponding Int color of this String.

Link copied to clipboard
@RequiresApi(value = 26)
inline fun Int.toColorLong(): Long

Converts the specified ARGB color int to an RGBA color long in the sRGB color space.

Link copied to clipboard
inline fun PointF.toPoint(): Point

Returns a Point representation of this point.

Link copied to clipboard
inline fun Point.toPointF(): PointF

Returns a PointF representation of this point.

Link copied to clipboard
inline fun RectF.toRect(): Rect

Returns a Rect representation of this rectangle. The resulting rect will be sized such that this rect can fit within it.

Link copied to clipboard
inline fun Rect.toRectF(): RectF

Returns a RectF representation of this rectangle.

Link copied to clipboard
inline fun Rect.toRegion(): Region

Returns a Region representation of this rectangle.

inline fun RectF.toRegion(): Region

Returns a Region representation of this rectangle. The resulting rect will be sized such that this rect can fit within it.

Link copied to clipboard

Creates a new PorterDuffXfermode that uses this PorterDuff.Mode as the alpha compositing or blending mode.

Link copied to clipboard
inline fun RectF.transform(m: Matrix): RectF

Transform this rectangle in place using the supplied Matrix and returns this rectangle.

inline fun Shader.transform(block: Matrix.() -> Unit)

Wrap the specified block in calls to Shader.getLocalMatrix and Shader.setLocalMatrix.

Link copied to clipboard
fun translationMatrix(tx: Float = 0.0f, ty: Float = 0.0f): Matrix

Creates a translation matrix with the translation amounts tx and ty respectively on the x and y axis.

Link copied to clipboard
inline operator fun Point.unaryMinus(): Point
inline operator fun PointF.unaryMinus(): PointF

Returns a new point representing the negation of this point.

inline operator fun Region.unaryMinus(): Region

Returns the negation of this region as a new region.

Link copied to clipboard
inline fun Matrix.values(): FloatArray

Returns the 9 values of this Matrix as a new array of floats.

Link copied to clipboard
inline fun Canvas.withClip(clipPath: Path, block: Canvas.() -> Unit)

Wrap the specified block in calls to Canvas.save/Canvas.clipPath and Canvas.restoreToCount.

inline fun Canvas.withClip(clipRect: Rect, block: Canvas.() -> Unit)
inline fun Canvas.withClip(clipRect: RectF, block: Canvas.() -> Unit)
inline fun Canvas.withClip(left: Float, top: Float, right: Float, bottom: Float, block: Canvas.() -> Unit)
inline fun Canvas.withClip(left: Int, top: Int, right: Int, bottom: Int, block: Canvas.() -> Unit)

Wrap the specified block in calls to Canvas.save/Canvas.clipRect and Canvas.restoreToCount.

Link copied to clipboard
inline fun Canvas.withMatrix(matrix: Matrix = Matrix(), block: Canvas.() -> Unit)

Wrap the specified block in calls to Canvas.save/Canvas.concat and Canvas.restoreToCount.

Link copied to clipboard
inline fun Canvas.withRotation(degrees: Float = 0.0f, pivotX: Float = 0.0f, pivotY: Float = 0.0f, block: Canvas.() -> Unit)

Wrap the specified block in calls to Canvas.save/Canvas.rotate and Canvas.restoreToCount.

Link copied to clipboard
inline fun Canvas.withSave(block: Canvas.() -> Unit)

Wrap the specified block in calls to Canvas.save and Canvas.restoreToCount.

Link copied to clipboard
inline fun Canvas.withScale(x: Float = 1.0f, y: Float = 1.0f, pivotX: Float = 0.0f, pivotY: Float = 0.0f, block: Canvas.() -> Unit)

Wrap the specified block in calls to Canvas.save/Canvas.scale and Canvas.restoreToCount.

Link copied to clipboard
inline fun Canvas.withSkew(x: Float = 0.0f, y: Float = 0.0f, block: Canvas.() -> Unit)

Wrap the specified block in calls to Canvas.save/Canvas.skew and Canvas.restoreToCount.

Link copied to clipboard
inline fun Canvas.withTranslation(x: Float = 0.0f, y: Float = 0.0f, block: Canvas.() -> Unit)

Wrap the specified block in calls to Canvas.save/Canvas.translate and Canvas.restoreToCount.

Link copied to clipboard
infix inline fun Path.xor(p: Path): Path

Returns the union minus the intersection of two paths as a new Path.

infix inline fun Rect.xor(r: Rect): Region

Returns the union minus the intersection of two rectangles as a new region.

infix inline fun RectF.xor(r: RectF): Region

Returns the union minus the intersection of two rectangles as a new region. The two rectangles are first converted to Rect using RectF.toRect.

infix inline fun Region.xor(r: Rect): Region

Return the union minus the intersection of this region and the specified Rect as a new region.

infix inline fun Region.xor(r: Region): Region

Return the union minus the intersection of this region and the specified region as a new region.