Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

androidx.core.graphics

Classes

BitmapCompat

Helper for accessing features in android.graphics.Bitmap.

BlendModeColorFilterCompat

Helper for accessing ColorFilter APIs on various API levels of the platform

ColorUtils

A set of color-related utility methods, building upon those available in Color.

Insets

An Insets instance holds four integer offsets which describe changes to the four edges of a Rectangle.

PaintCompat

Helper for accessing features in Paint.

PathSegment

A line segment that represents an approximate fraction of a Path after flattening.

PathUtils

A set of path-related utility methods.

TypefaceCompat

Helper for accessing features in Typeface.

Enums

BlendModeCompat

Compat version of android.graphics.BlendMode, usages of BlendModeCompat will map to android.graphics.PorterDuff.Mode wherever possible

Top-level functions summary

Bitmap
createBitmap(width: Int, height: Int, config: Config = Bitmap.Config.ARGB_8888)

Returns a mutable bitmap with the specified width and height.

Bitmap
createBitmap(width: Int, height: Int, config: Config = Bitmap.Config.ARGB_8888, hasAlpha: Boolean = true, colorSpace: ColorSpace = ColorSpace.get(ColorSpace.Named.SRGB))

Returns a mutable bitmap with the specified width and height.

Matrix
rotationMatrix(degrees: Float, px: Float = 0.0f, py: Float = 0.0f)

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

Matrix
scaleMatrix(sx: Float = 1.0f, sy: Float = 1.0f)

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

Matrix
translationMatrix(tx: Float = 0.0f, ty: Float = 0.0f)

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

Extension functions summary

For android.graphics.Bitmap
Bitmap
Bitmap.applyCanvas(block: Canvas.() -> Unit)

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

operator Boolean

Returns true if the specified point is inside the bitmap.

operator Boolean

Returns true if the specified point is inside the bitmap.

operator Int
Bitmap.get(x: Int, y: Int)

Returns the value of the pixel at the specified location.

Bitmap
Bitmap.scale(width: Int, height: Int, filter: Boolean = true)

Creates a new bitmap, scaled from this bitmap, when possible.

operator Unit
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.

For android.graphics.Canvas
Unit
Canvas.withClip(clipRect: Rect, block: Canvas.() -> Unit)

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

Unit
Canvas.withClip(clipRect: RectF, block: Canvas.() -> Unit)

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

Unit
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.

Unit
Canvas.withClip(left: Float, top: Float, right: Float, bottom: Float, block: Canvas.() -> Unit)

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

Unit
Canvas.withClip(clipPath: Path, block: Canvas.() -> Unit)

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

Unit
Canvas.withMatrix(matrix: Matrix = Matrix(), block: Canvas.() -> Unit)

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

Unit
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.

Unit
Canvas.withSave(block: Canvas.() -> Unit)

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

Unit
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.

Unit
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.

Unit
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.

For android.graphics.Color
operator Float

Returns the first component of the color.

operator Float

Returns the second component of the color.

operator Float

Returns the third component of the color.

operator Float

Returns the fourth component of the color.

infix Color
Color.convertTo(colorSpace: Named)

Converts the color receiver to a color in the specified color space.

infix Color
Color.convertTo(colorSpace: ColorSpace)

Converts the color receiver to a color in the specified color space.

operator Color

Composites two translucent colors together.

For android.graphics.ImageDecoder.Source
Bitmap
Source.decodeBitmap(crossinline action: ImageDecoder.(info: ImageInfo, source: Source) -> Unit)

Create a Bitmap from a Source

Drawable
Source.decodeDrawable(crossinline action: ImageDecoder.(info: ImageInfo, source: Source) -> Unit)

Create a Drawable from a Source

For android.graphics.Matrix
operator Matrix

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

FloatArray

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

For android.graphics.Paint
Boolean
Paint.setBlendMode(blendModeCompat: BlendModeCompat?)

Convenience method to configure the BlendMode of a Paint in a backward compatible way.

For android.graphics.Path
infix Path

Returns the intersection of two paths as a new Path.

Iterable<PathSegment>
Path.flatten(error: Float = 0.5f)

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

operator Path

Returns the difference of two paths as a new Path.

infix Path
Path.or(p: Path)

Returns the union of two paths as a new Path.

operator Path

Returns the union of two paths as a new Path.

infix Path

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

For android.graphics.Picture
Picture
Picture.record(width: Int, height: Int, block: Canvas.() -> Unit)

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

For android.graphics.Point
operator Int

Returns the x coordinate of this point.

operator Int

Returns the y coordinate of this point.

operator Point

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

operator Point

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

operator Point

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

operator Point
Point.plus(xy: Int)

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

PointF

Returns a PointF representation of this point.

operator Point

Returns a new point representing the negation of this point.

For android.graphics.PointF
operator Float

Returns the x coordinate of this point.

operator Float

Returns the y coordinate of this point.

operator PointF

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

operator 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.

operator PointF

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

operator PointF

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

Point

Returns a Point representation of this point.

operator PointF

Returns a new point representing the negation of this point.

For android.graphics.PorterDuff.Mode
PorterDuffColorFilter

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

PorterDuffXfermode

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

For android.graphics.Rect
infix Rect

Returns the intersection of two rectangles as a new rectangle.

operator Int

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

operator Int

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

operator Int

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

operator Int

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

operator Boolean

Returns true if the specified point is inside the rectangle.

operator Region

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

operator Rect
Rect.minus(xy: Int)

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

operator Rect

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

infix Rect
Rect.or(r: Rect)

Returns the union of two rectangles as a new rectangle.

operator