Class Canvas

  • All Implemented Interfaces:
    java.lang.AutoCloseable
    Direct Known Subclasses:
    PaintFilterCanvas

    public class Canvas
    extends Managed
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.Object _owner  
      • Fields inherited from class io.github.humbleui.skija.impl.Native

        _ptr
    • Constructor Summary

      Constructors 
      Constructor Description
      Canvas​(long ptr, boolean managed, java.lang.Object owner)  
      Canvas​(@NotNull Bitmap bitmap)
      Constructs a canvas that draws into bitmap.
      Canvas​(@NotNull Bitmap bitmap, @NotNull SurfaceProps surfaceProps)
      Constructs a canvas that draws into bitmap.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void _nClear​(long ptr, int color)  
      static void _nClipPath​(long ptr, long nativePath, int mode, boolean antiAlias)  
      static void _nClipRect​(long ptr, float left, float top, float right, float bottom, int mode, boolean antiAlias)  
      static void _nClipRegion​(long ptr, long nativeRegion, int mode)  
      static void _nClipRRect​(long ptr, float left, float top, float right, float bottom, float[] radii, int mode, boolean antiAlias)  
      static void _nConcat​(long ptr, float[] matrix)  
      static void _nConcat44​(long ptr, float[] matrix)  
      static void _nDrawArc​(long ptr, float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean includeCenter, long paintPtr)  
      static void _nDrawColor​(long ptr, int color, int blendMode)  
      static void _nDrawColor4f​(long ptr, float r, float g, float b, float a, int blendMode)  
      static void _nDrawDrawable​(long ptr, long drawablePrt, float[] matrix)  
      static void _nDrawDRRect​(long ptr, float ol, float ot, float or, float ob, float[] oradii, float il, float it, float ir, float ib, float[] iradii, long paintPtr)  
      static void _nDrawImageNine​(long ptr, long nativeImage, int cl, int ct, int cr, int cb, float dl, float dt, float dr, float db, int filterMode, long paintPtr)  
      static void _nDrawImageRect​(long ptr, long nativeImage, float sl, float st, float sr, float sb, float dl, float dt, float dr, float db, long samplingMode, long paintPtr, boolean strict)  
      static void _nDrawLine​(long ptr, float x0, float y0, float x1, float y1, long paintPtr)  
      static void _nDrawOval​(long ptr, float left, float top, float right, float bottom, long paint)  
      static void _nDrawPaint​(long ptr, long paintPtr)  
      static void _nDrawPatch​(long ptr, float[] cubics, int[] colors, float[] texCoords, int blendMode, long paintPtr)  
      static void _nDrawPath​(long ptr, long nativePath, long paintPtr)  
      static void _nDrawPicture​(long ptr, long picturePtr, float[] matrix, long paintPtr)  
      static void _nDrawPoint​(long ptr, float x, float y, long paintPtr)  
      static void _nDrawPoints​(long ptr, int mode, float[] coords, long paintPtr)  
      static void _nDrawRect​(long ptr, float left, float top, float right, float bottom, long paintPtr)  
      static void _nDrawRegion​(long ptr, long nativeRegion, long paintPtr)  
      static void _nDrawRRect​(long ptr, float left, float top, float right, float bottom, float[] radii, long paintPtr)  
      static void _nDrawString​(long ptr, java.lang.String string, float x, float y, long font, long paint)  
      static void _nDrawTextBlob​(long ptr, long blob, float x, float y, long paint)  
      static void _nDrawVertices​(long ptr, int verticesMode, float[] cubics, int[] colors, float[] texCoords, short[] indices, int blendMode, long paintPtr)  
      static SurfaceProps _nGetBaseProps​(long ptr)  
      static long _nGetFinalizer()  
      static float[] _nGetLocalToDevice​(long ptr)  
      static int _nGetSaveCount​(long ptr)  
      static long _nGetSurface​(long ptr)  
      static SurfaceProps _nGetTopProps​(long ptr)  
      static long _nMakeFromBitmap​(long bitmapPtr, int flags, int pixelGeometry)  
      static boolean _nQuickReject​(long ptr, float left, float top, float right, float bottom)  
      static boolean _nQuickRejectPath​(long ptr, long pathPtr)  
      static boolean _nReadPixels​(long ptr, long bitmapPtr, int srcX, int srcY)  
      static void _nResetMatrix​(long ptr)  
      static void _nRestore​(long ptr)  
      static void _nRestoreToCount​(long ptr, int saveCount)  
      static int _nSave​(long ptr)  
      static int _nSaveLayer​(long ptr, long paintPtr)  
      static int _nSaveLayerAlpha​(long ptr, int alpha)  
      static int _nSaveLayerAlphaRect​(long ptr, float left, float top, float right, float bottom, int alpha)  
      static int _nSaveLayerRec​(long ptr, long paintPtr, long backdropPtr, int flags)  
      static int _nSaveLayerRecRect​(long ptr, float left, float top, float right, float bottom, long paintPtr, long backdropPtr, int flags)  
      static int _nSaveLayerRect​(long ptr, float left, float top, float right, float bottom, long paintPtr)  
      static void _nSetMatrix​(long ptr, float[] matrix)  
      static void _nSetMatrix44​(long ptr, float[] matrix)  
      static boolean _nWritePixels​(long ptr, long bitmapPtr, int x, int y)  
      @NotNull Canvas clear​(int color)  
      @NotNull Canvas clipPath​(@NotNull Path p)  
      @NotNull Canvas clipPath​(@NotNull Path p, boolean antiAlias)  
      @NotNull Canvas clipPath​(@NotNull Path p, @NotNull ClipMode mode)  
      @NotNull Canvas clipPath​(@NotNull Path p, @NotNull ClipMode mode, boolean antiAlias)  
      @NotNull Canvas clipRect​(@NotNull io.github.humbleui.types.Rect r)  
      @NotNull Canvas clipRect​(@NotNull io.github.humbleui.types.Rect r, boolean antiAlias)  
      @NotNull Canvas clipRect​(@NotNull io.github.humbleui.types.Rect r, @NotNull ClipMode mode)  
      @NotNull Canvas clipRect​(@NotNull io.github.humbleui.types.Rect r, @NotNull ClipMode mode, boolean antiAlias)  
      @NotNull Canvas clipRegion​(@NotNull Region r)  
      @NotNull Canvas clipRegion​(@NotNull Region r, @NotNull ClipMode mode)  
      @NotNull Canvas clipRRect​(@NotNull io.github.humbleui.types.RRect r)  
      @NotNull Canvas clipRRect​(@NotNull io.github.humbleui.types.RRect r, boolean antiAlias)  
      @NotNull Canvas clipRRect​(@NotNull io.github.humbleui.types.RRect r, @NotNull ClipMode mode)  
      @NotNull Canvas clipRRect​(@NotNull io.github.humbleui.types.RRect r, @NotNull ClipMode mode, boolean antiAlias)  
      @NotNull Canvas concat​(@NotNull Matrix33 matrix)  
      @NotNull Canvas concat​(@NotNull Matrix44 matrix)  
      @NotNull Canvas drawArc​(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean includeCenter, @NotNull Paint paint)  
      @NotNull Canvas drawCircle​(float x, float y, float radius, @NotNull Paint paint)  
      @NotNull Canvas drawColor​(int color)  
      @NotNull Canvas drawColor​(int color, @NotNull BlendMode mode)  
      @NotNull Canvas drawColor​(@NotNull Color4f color)  
      @NotNull Canvas drawColor​(@NotNull Color4f color, @NotNull BlendMode mode)  
      @NotNull Canvas drawDrawable​(@NotNull Drawable drawable)
      Draws Drawable drawable using clip and matrix.
      @NotNull Canvas drawDrawable​(@NotNull Drawable drawable, float x, float y)
      Draws Drawable drawable using clip and matrix, offset by (x, y).
      @NotNull Canvas drawDrawable​(@NotNull Drawable drawable, @Nullable Matrix33 matrix)
      Draws Drawable drawable using clip and matrix, concatenated with optional matrix.
      @NotNull Canvas drawDRRect​(@NotNull io.github.humbleui.types.RRect outer, @NotNull io.github.humbleui.types.RRect inner, @NotNull Paint paint)  
      @NotNull Canvas drawImage​(@NotNull Image image, float left, float top)  
      @NotNull Canvas drawImage​(@NotNull Image image, float left, float top, @Nullable Paint paint)  
      @NotNull Canvas drawImageNine​(@NotNull Image image, @NotNull io.github.humbleui.types.IRect center, @NotNull io.github.humbleui.types.Rect dst, @NotNull FilterMode filterMode, @Nullable Paint paint)  
      @NotNull Canvas drawImageRect​(@NotNull Image image, @NotNull io.github.humbleui.types.Rect dst)  
      @NotNull Canvas drawImageRect​(@NotNull Image image, @NotNull io.github.humbleui.types.Rect src, @NotNull io.github.humbleui.types.Rect dst)  
      @NotNull Canvas drawImageRect​(@NotNull Image image, @NotNull io.github.humbleui.types.Rect src, @NotNull io.github.humbleui.types.Rect dst, @NotNull SamplingMode samplingMode, @Nullable Paint paint, boolean strict)  
      @NotNull Canvas drawImageRect​(@NotNull Image image, @NotNull io.github.humbleui.types.Rect src, @NotNull io.github.humbleui.types.Rect dst, @Nullable Paint paint)  
      @NotNull Canvas drawImageRect​(@NotNull Image image, @NotNull io.github.humbleui.types.Rect src, @NotNull io.github.humbleui.types.Rect dst, @Nullable Paint paint, boolean strict)  
      @NotNull Canvas drawImageRect​(@NotNull Image image, @NotNull io.github.humbleui.types.Rect dst, @Nullable Paint paint)  
      @NotNull Canvas drawLine​(float x0, float y0, float x1, float y1, @NotNull Paint paint)  
      @NotNull Canvas drawLines​(@org.jetbrains.annotations.NotNull float[] coords, @NotNull Paint paint)
      Draws pts using clip, Matrix and Paint paint.
      @NotNull Canvas drawLines​(@NotNull io.github.humbleui.types.Point[] coords, @NotNull Paint paint)
      Draws pts using clip, Matrix and Paint paint.
      @NotNull Canvas drawOval​(@NotNull io.github.humbleui.types.Rect r, @NotNull Paint paint)  
      @NotNull Canvas drawPaint​(@NotNull Paint paint)  
      @NotNull Canvas drawPatch​(@NotNull io.github.humbleui.types.Point[] cubics, @org.jetbrains.annotations.NotNull int[] colors, @NotNull Paint paint)
      Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.
      @NotNull Canvas drawPatch​(@NotNull io.github.humbleui.types.Point[] cubics, @org.jetbrains.annotations.NotNull int[] colors, @Nullable io.github.humbleui.types.Point[] texCoords, @NotNull BlendMode mode, @NotNull Paint paint)
      Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.
      @NotNull Canvas drawPatch​(@NotNull io.github.humbleui.types.Point[] cubics, @org.jetbrains.annotations.NotNull int[] colors, @Nullable io.github.humbleui.types.Point[] texCoords, @NotNull Paint paint)
      Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.
      @NotNull Canvas drawPath​(@NotNull Path path, @NotNull Paint paint)  
      @NotNull Canvas drawPicture​(@NotNull Picture picture)  
      @NotNull Canvas drawPicture​(@NotNull Picture picture, @Nullable Matrix33 matrix, @Nullable Paint paint)  
      @NotNull Canvas drawPoint​(float x, float y, @NotNull Paint paint)  
      @NotNull Canvas drawPoints​(@org.jetbrains.annotations.NotNull float[] coords, @NotNull Paint paint)
      Draws pts using clip, Matrix and Paint paint.
      @NotNull Canvas drawPoints​(@NotNull io.github.humbleui.types.Point[] coords, @NotNull Paint paint)
      Draws pts using clip, Matrix and Paint paint.
      @NotNull Canvas drawPolygon​(@org.jetbrains.annotations.NotNull float[] coords, @NotNull Paint paint)
      Draws pts using clip, Matrix and Paint paint.
      @NotNull Canvas drawPolygon​(@NotNull io.github.humbleui.types.Point[] coords, @NotNull Paint paint)
      Draws pts using clip, Matrix and Paint paint.
      @NotNull Canvas drawRect​(@NotNull io.github.humbleui.types.Rect r, @NotNull Paint paint)  
      @NotNull Canvas drawRectShadow​(@NotNull io.github.humbleui.types.Rect r, float dx, float dy, float blur, float spread, int color)  
      @NotNull Canvas drawRectShadow​(@NotNull io.github.humbleui.types.Rect r, float dx, float dy, float blur, int color)  
      @NotNull Canvas drawRectShadowNoclip​(@NotNull io.github.humbleui.types.Rect r, float dx, float dy, float blur, float spread, int color)  
      @NotNull Canvas drawRegion​(@NotNull Region r, @NotNull Paint paint)  
      @NotNull Canvas drawRRect​(@NotNull io.github.humbleui.types.RRect r, @NotNull Paint paint)  
      @NotNull Canvas drawString​(@NotNull java.lang.String s, float x, float y, Font font, @NotNull Paint paint)  
      @NotNull Canvas drawTextBlob​(@NotNull TextBlob blob, float x, float y, @NotNull Paint paint)  
      @NotNull Canvas drawTextLine​(@NotNull TextLine line, float x, float y, @NotNull Paint paint)  
      @NotNull Canvas drawTriangleFan​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @NotNull Paint paint)
      Draws a triangle fan mesh, using clip and Matrix.
      @NotNull Canvas drawTriangleFan​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @Nullable io.github.humbleui.types.Point[] texCoords, @org.jetbrains.annotations.Nullable short[] indices, @NotNull BlendMode mode, @NotNull Paint paint)
      Draws a triangle fan mesh, using clip and Matrix.
      @NotNull Canvas drawTriangleFan​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @Nullable io.github.humbleui.types.Point[] texCoords, @org.jetbrains.annotations.Nullable short[] indices, @NotNull Paint paint)
      Draws a triangle fan mesh, using clip and Matrix.
      @NotNull Canvas drawTriangles​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @NotNull Paint paint)
      Draws a triangle mesh, using clip and Matrix.
      @NotNull Canvas drawTriangles​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @Nullable io.github.humbleui.types.Point[] texCoords, @org.jetbrains.annotations.Nullable short[] indices, @NotNull BlendMode mode, @NotNull Paint paint)
      Draws a triangle mesh, using clip and Matrix.
      @NotNull Canvas drawTriangles​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @Nullable io.github.humbleui.types.Point[] texCoords, @org.jetbrains.annotations.Nullable short[] indices, @NotNull Paint paint)
      Draws a triangle mesh, using clip and Matrix.
      @NotNull Canvas drawTriangleStrip​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @NotNull Paint paint)
      Draws a triangle strip mesh, using clip and Matrix.
      @NotNull Canvas drawTriangleStrip​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @Nullable io.github.humbleui.types.Point[] texCoords, @org.jetbrains.annotations.Nullable short[] indices, @NotNull BlendMode mode, @NotNull Paint paint)
      Draws a triangle strip mesh, using clip and Matrix.
      @NotNull Canvas drawTriangleStrip​(@NotNull io.github.humbleui.types.Point[] positions, @org.jetbrains.annotations.Nullable int[] colors, @Nullable io.github.humbleui.types.Point[] texCoords, @org.jetbrains.annotations.Nullable short[] indices, @NotNull Paint paint)
      Draws a triangle strip mesh, using clip and Matrix.
      @NotNull SurfaceProps getBaseProps()
      Returns the SurfaceProps associated with the canvas (i.e., at the base of the layer stack).
      @NotNull Matrix44 getLocalToDevice()
      Returns the total transformation matrix for the canvas.
      @NotNull Matrix33 getLocalToDeviceAsMatrix33()  
      int getSaveCount()  
      @Nullable Surface getSurface()  
      @NotNull SurfaceProps getTopProps()
      Returns the SurfaceProps associated with the canvas that are currently active (i.e., at the top of the layer stack).
      @org.jetbrains.annotations.NotNull boolean quickReject​(@NotNull Path path)  
      @org.jetbrains.annotations.NotNull boolean quickReject​(@NotNull io.github.humbleui.types.Rect r)  
      boolean readPixels​(@NotNull Bitmap bitmap, int srcX, int srcY)
      Copies Rect of pixels from Canvas into bitmap.
      @NotNull Canvas resetMatrix()
      Sets SkMatrix to the identity matrix.
      @NotNull Canvas restore()  
      @NotNull Canvas restoreToCount​(int saveCount)  
      @NotNull Canvas rotate​(float deg)  
      int save()  
      int saveLayer​(float left, float top, float right, float bottom, @Nullable Paint paint)  
      int saveLayer​(@NotNull SaveLayerRec layerRec)
      Saves matrix and clip, and allocates Bitmap for subsequent drawing.
      int saveLayer​(@Nullable io.github.humbleui.types.Rect bounds, @Nullable Paint paint)
      Saves Matrix and clip, and allocates a Bitmap for subsequent drawing.
      int saveLayerAlpha​(@Nullable io.github.humbleui.types.Rect bounds, int alpha)
      Saves matrix and clip, and allocates bitmap for subsequent drawing.
      @NotNull Canvas scale​(float sx, float sy)  
      @NotNull Canvas setMatrix​(@NotNull Matrix33 matrix)
      Replaces Matrix with matrix.
      @NotNull Canvas setMatrix​(@NotNull Matrix44 matrix)
      Replaces Matrix with matrix.
      @NotNull Canvas skew​(float sx, float sy)  
      @NotNull Canvas translate​(float dx, float dy)  
      boolean writePixels​(@NotNull Bitmap bitmap, int x, int y)
      Copies Rect from pixels to Canvas.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _owner

        @Internal
        public final java.lang.Object _owner
    • Constructor Detail

      • Canvas

        @Internal
        public Canvas​(long ptr,
                      boolean managed,
                      java.lang.Object owner)
      • Canvas

        public Canvas​(@NotNull
                      @NotNull Bitmap bitmap)

        Constructs a canvas that draws into bitmap. Sets default pixel geometry in constructed Surface.

        Bitmap is copied so that subsequently editing bitmap will not affect constructed Canvas.

        May be deprecated in the future.

        Parameters:
        bitmap - width, height, ColorType, ColorAlphaType, and pixel storage of raster surface
        See Also:
        https://fiddle.skia.org/c/@Canvas_copy_const_SkBitmap
      • Canvas

        public Canvas​(@NotNull
                      @NotNull Bitmap bitmap,
                      @NotNull
                      @NotNull SurfaceProps surfaceProps)

        Constructs a canvas that draws into bitmap. Use props to match the device characteristics, like LCD striping.

        Bitmap is copied so that subsequently editing bitmap will not affect constructed Canvas.

        Parameters:
        bitmap - width, height, ColorType, ColorAlphaType, and pixel storage of raster surface
        surfaceProps - order and orientation of RGB striping; and whether to use device independent fonts
        See Also:
        https://fiddle.skia.org/c/@Canvas_const_SkBitmap_const_SkSurfaceProps
    • Method Detail

      • getBaseProps

        @NotNull
        public @NotNull SurfaceProps getBaseProps()
        Returns the SurfaceProps associated with the canvas (i.e., at the base of the layer stack).
        Returns:
        SurfaceProps
      • getTopProps

        @NotNull
        public @NotNull SurfaceProps getTopProps()
        Returns the SurfaceProps associated with the canvas that are currently active (i.e., at the top of the layer stack). This can differ from {getBaseProps()} depending on the flags passed to saveLayer.
        Returns:
        SurfaceProps active in the current/top layer
      • getSurface

        @Nullable
        public @Nullable Surface getSurface()
      • drawPoint

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawPoint​(float x,
                                         float y,
                                         @NotNull
                                         @NotNull Paint paint)
      • drawPoints

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawPoints​(@NotNull
                                          @NotNull io.github.humbleui.types.Point[] coords,
                                          @NotNull
                                          @NotNull Paint paint)

        Draws pts using clip, Matrix and Paint paint.

        The shape of point drawn depends on paint PaintStrokeCap. If paint is set to PaintStrokeCap.ROUND, each point draws a circle of diameter Paint stroke width. If paint is set to PaintStrokeCap.SQUARE or PaintStrokeCap.BUTT, each point draws a square of width and height Paint stroke width.

        Each line segment respects paint PaintStrokeCap and Paint stroke width. PaintMode is ignored, as if were set to PaintMode.STROKE.

        Always draws each element one at a time; is not affected by PaintStrokeJoin, and unlike drawPath(), does not create a mask from all points and lines before drawing.

        Parameters:
        coords - array of points to draw
        paint - stroke, blend, color, and so on, used to draw
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawPoints
      • drawPoints

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawPoints​(@NotNull
                                          @org.jetbrains.annotations.NotNull float[] coords,
                                          @NotNull
                                          @NotNull Paint paint)

        Draws pts using clip, Matrix and Paint paint.

        The shape of point drawn depends on paint PaintStrokeCap. If paint is set to PaintStrokeCap.ROUND, each point draws a circle of diameter Paint stroke width. If paint is set to PaintStrokeCap.SQUARE or PaintStrokeCap.BUTT, each point draws a square of width and height Paint stroke width.

        Each line segment respects paint PaintStrokeCap and Paint stroke width. PaintMode is ignored, as if were set to PaintMode.STROKE.

        Always draws each element one at a time; is not affected by PaintStrokeJoin, and unlike drawPath(), does not create a mask from all points and lines before drawing.

        Parameters:
        coords - array of points to draw
        paint - stroke, blend, color, and so on, used to draw
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawPoints
      • drawLines

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawLines​(@NotNull
                                         @NotNull io.github.humbleui.types.Point[] coords,
                                         @NotNull
                                         @NotNull Paint paint)

        Draws pts using clip, Matrix and Paint paint.

        Each pair of points draws a line segment. One line is drawn for every two points; each point is used once. If count is odd, the final point is ignored.

        Each line segment respects paint PaintStrokeCap and Paint stroke width. PaintMode is ignored, as if were set to PaintMode.STROKE.

        Always draws each element one at a time; is not affected by PaintStrokeJoin, and unlike drawPath(), does not create a mask from all points and lines before drawing.

        Parameters:
        coords - array of points to draw
        paint - stroke, blend, color, and so on, used to draw
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawPoints
      • drawLines

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawLines​(@NotNull
                                         @org.jetbrains.annotations.NotNull float[] coords,
                                         @NotNull
                                         @NotNull Paint paint)

        Draws pts using clip, Matrix and Paint paint.

        Each pair of points draws a line segment. One line is drawn for every two points; each point is used once. If count is odd, the final point is ignored.

        Each line segment respects paint PaintStrokeCap and Paint stroke width. PaintMode is ignored, as if were set to PaintMode.STROKE.

        Always draws each element one at a time; is not affected by PaintStrokeJoin, and unlike drawPath(), does not create a mask from all points and lines before drawing.

        Parameters:
        coords - array of points to draw
        paint - stroke, blend, color, and so on, used to draw
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawPoints
      • drawPolygon

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawPolygon​(@NotNull
                                           @NotNull io.github.humbleui.types.Point[] coords,
                                           @NotNull
                                           @NotNull Paint paint)

        Draws pts using clip, Matrix and Paint paint.

        Each adjacent pair of points draws a line segment. count minus one lines are drawn; the first and last point are used once.

        Each line segment respects paint PaintStrokeCap and Paint stroke width. PaintMode is ignored, as if were set to PaintMode.STROKE.

        Always draws each element one at a time; is not affected by PaintStrokeJoin, and unlike drawPath(), does not create a mask from all points and lines before drawing.

        Parameters:
        coords - array of points to draw
        paint - stroke, blend, color, and so on, used to draw
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawPoints
      • drawPolygon

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawPolygon​(@NotNull
                                           @org.jetbrains.annotations.NotNull float[] coords,
                                           @NotNull
                                           @NotNull Paint paint)

        Draws pts using clip, Matrix and Paint paint.

        Each adjacent pair of points draws a line segment. count minus one lines are drawn; the first and last point are used once.

        Each line segment respects paint PaintStrokeCap and Paint stroke width. PaintMode is ignored, as if were set to PaintMode.STROKE.

        Always draws each element one at a time; is not affected by PaintStrokeJoin, and unlike drawPath(), does not create a mask from all points and lines before drawing.

        Parameters:
        coords - array of points to draw
        paint - stroke, blend, color, and so on, used to draw
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawPoints
      • drawLine

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawLine​(float x0,
                                        float y0,
                                        float x1,
                                        float y1,
                                        @NotNull
                                        @NotNull Paint paint)
      • drawArc

        @NotNull
        @Contract("_, _, _, _, _, _, _, _ -> this")
        public @NotNull Canvas drawArc​(float left,
                                       float top,
                                       float right,
                                       float bottom,
                                       float startAngle,
                                       float sweepAngle,
                                       boolean includeCenter,
                                       @NotNull
                                       @NotNull Paint paint)
      • drawRect

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawRect​(@NotNull
                                        @NotNull io.github.humbleui.types.Rect r,
                                        @NotNull
                                        @NotNull Paint paint)
      • drawOval

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawOval​(@NotNull
                                        @NotNull io.github.humbleui.types.Rect r,
                                        @NotNull
                                        @NotNull Paint paint)
      • drawCircle

        @NotNull
        @Contract("_, _, _, _ -> this")
        public @NotNull Canvas drawCircle​(float x,
                                          float y,
                                          float radius,
                                          @NotNull
                                          @NotNull Paint paint)
      • drawRRect

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawRRect​(@NotNull
                                         @NotNull io.github.humbleui.types.RRect r,
                                         @NotNull
                                         @NotNull Paint paint)
      • quickReject

        @NotNull
        @Contract("_ -> this")
        public @org.jetbrains.annotations.NotNull boolean quickReject​(@NotNull
                                                                      @NotNull io.github.humbleui.types.Rect r)
      • quickReject

        @NotNull
        @Contract("_ -> this")
        public @org.jetbrains.annotations.NotNull boolean quickReject​(@NotNull
                                                                      @NotNull Path path)
      • drawDRRect

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawDRRect​(@NotNull
                                          @NotNull io.github.humbleui.types.RRect outer,
                                          @NotNull
                                          @NotNull io.github.humbleui.types.RRect inner,
                                          @NotNull
                                          @NotNull Paint paint)
      • drawRectShadow

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawRectShadow​(@NotNull
                                              @NotNull io.github.humbleui.types.Rect r,
                                              float dx,
                                              float dy,
                                              float blur,
                                              int color)
      • drawRectShadow

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawRectShadow​(@NotNull
                                              @NotNull io.github.humbleui.types.Rect r,
                                              float dx,
                                              float dy,
                                              float blur,
                                              float spread,
                                              int color)
      • drawRectShadowNoclip

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawRectShadowNoclip​(@NotNull
                                                    @NotNull io.github.humbleui.types.Rect r,
                                                    float dx,
                                                    float dy,
                                                    float blur,
                                                    float spread,
                                                    int color)
      • drawPath

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawPath​(@NotNull
                                        @NotNull Path path,
                                        @NotNull
                                        @NotNull Paint paint)
      • drawImage

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawImage​(@NotNull
                                         @NotNull Image image,
                                         float left,
                                         float top)
      • drawImage

        @NotNull
        @Contract("_, _, _, _ -> this")
        public @NotNull Canvas drawImage​(@NotNull
                                         @NotNull Image image,
                                         float left,
                                         float top,
                                         @Nullable
                                         @Nullable Paint paint)
      • drawImageRect

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawImageRect​(@NotNull
                                             @NotNull Image image,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect dst)
      • drawImageRect

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawImageRect​(@NotNull
                                             @NotNull Image image,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect dst,
                                             @Nullable
                                             @Nullable Paint paint)
      • drawImageRect

        @NotNull
        @Contract("_, _, _, _ -> this")
        public @NotNull Canvas drawImageRect​(@NotNull
                                             @NotNull Image image,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect src,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect dst)
      • drawImageRect

        @NotNull
        @Contract("_, _, _, _ -> this")
        public @NotNull Canvas drawImageRect​(@NotNull
                                             @NotNull Image image,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect src,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect dst,
                                             @Nullable
                                             @Nullable Paint paint)
      • drawImageRect

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawImageRect​(@NotNull
                                             @NotNull Image image,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect src,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect dst,
                                             @Nullable
                                             @Nullable Paint paint,
                                             boolean strict)
      • drawImageRect

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawImageRect​(@NotNull
                                             @NotNull Image image,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect src,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect dst,
                                             @NotNull
                                             @NotNull SamplingMode samplingMode,
                                             @Nullable
                                             @Nullable Paint paint,
                                             boolean strict)
      • drawImageNine

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawImageNine​(@NotNull
                                             @NotNull Image image,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.IRect center,
                                             @NotNull
                                             @NotNull io.github.humbleui.types.Rect dst,
                                             @NotNull
                                             @NotNull FilterMode filterMode,
                                             @Nullable
                                             @Nullable Paint paint)
      • drawRegion

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawRegion​(@NotNull
                                          @NotNull Region r,
                                          @NotNull
                                          @NotNull Paint paint)
      • drawString

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawString​(@NotNull
                                          @NotNull java.lang.String s,
                                          float x,
                                          float y,
                                          Font font,
                                          @NotNull
                                          @NotNull Paint paint)
      • drawTextBlob

        @NotNull
        @Contract("_, _, _, _ -> this")
        public @NotNull Canvas drawTextBlob​(@NotNull
                                            @NotNull TextBlob blob,
                                            float x,
                                            float y,
                                            @NotNull
                                            @NotNull Paint paint)
      • drawTextLine

        @NotNull
        @Contract("_, _, _, _ -> this")
        public @NotNull Canvas drawTextLine​(@NotNull
                                            @NotNull TextLine line,
                                            float x,
                                            float y,
                                            @NotNull
                                            @NotNull Paint paint)
      • drawPicture

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas drawPicture​(@NotNull
                                           @NotNull Picture picture)
      • drawPicture

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawPicture​(@NotNull
                                           @NotNull Picture picture,
                                           @Nullable
                                           @Nullable Matrix33 matrix,
                                           @Nullable
                                           @Nullable Paint paint)
      • drawTriangles

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawTriangles​(@NotNull
                                             @NotNull io.github.humbleui.types.Point[] positions,
                                             @Nullable
                                             @org.jetbrains.annotations.Nullable int[] colors,
                                             @NotNull
                                             @NotNull Paint paint)

        Draws a triangle mesh, using clip and Matrix.

        If paint contains an Shader, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawTriangles

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawTriangles​(@NotNull
                                             @NotNull io.github.humbleui.types.Point[] positions,
                                             @Nullable
                                             @org.jetbrains.annotations.Nullable int[] colors,
                                             @Nullable
                                             @Nullable io.github.humbleui.types.Point[] texCoords,
                                             @Nullable
                                             @org.jetbrains.annotations.Nullable short[] indices,
                                             @NotNull
                                             @NotNull Paint paint)

        Draws a triangle mesh, using clip and Matrix.

        If paint contains an Shader and vertices does not contain texCoords, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        texCoords - Point array of texture coordinates, mapping Shader to corners; may be null
        indices - with which indices points should be drawn; may be null
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawTriangles

        @NotNull
        @Contract("_, _, _, _, _, _ -> this")
        public @NotNull Canvas drawTriangles​(@NotNull
                                             @NotNull io.github.humbleui.types.Point[] positions,
                                             @Nullable
                                             @org.jetbrains.annotations.Nullable int[] colors,
                                             @Nullable
                                             @Nullable io.github.humbleui.types.Point[] texCoords,
                                             @Nullable
                                             @org.jetbrains.annotations.Nullable short[] indices,
                                             @NotNull
                                             @NotNull BlendMode mode,
                                             @NotNull
                                             @NotNull Paint paint)

        Draws a triangle mesh, using clip and Matrix.

        If paint contains an Shader and vertices does not contain texCoords, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        texCoords - Point array of texture coordinates, mapping Shader to corners; may be null
        indices - with which indices points should be drawn; may be null
        mode - combines vertices colors with Shader, if both are present
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawTriangleStrip

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawTriangleStrip​(@NotNull
                                                 @NotNull io.github.humbleui.types.Point[] positions,
                                                 @Nullable
                                                 @org.jetbrains.annotations.Nullable int[] colors,
                                                 @NotNull
                                                 @NotNull Paint paint)

        Draws a triangle strip mesh, using clip and Matrix.

        If paint contains an Shader, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawTriangleStrip

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawTriangleStrip​(@NotNull
                                                 @NotNull io.github.humbleui.types.Point[] positions,
                                                 @Nullable
                                                 @org.jetbrains.annotations.Nullable int[] colors,
                                                 @Nullable
                                                 @Nullable io.github.humbleui.types.Point[] texCoords,
                                                 @Nullable
                                                 @org.jetbrains.annotations.Nullable short[] indices,
                                                 @NotNull
                                                 @NotNull Paint paint)

        Draws a triangle strip mesh, using clip and Matrix.

        If paint contains an Shader and vertices does not contain texCoords, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        texCoords - Point array of texture coordinates, mapping Shader to corners; may be null
        indices - with which indices points should be drawn; may be null
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawTriangleStrip

        @NotNull
        @Contract("_, _, _, _, _, _ -> this")
        public @NotNull Canvas drawTriangleStrip​(@NotNull
                                                 @NotNull io.github.humbleui.types.Point[] positions,
                                                 @Nullable
                                                 @org.jetbrains.annotations.Nullable int[] colors,
                                                 @Nullable
                                                 @Nullable io.github.humbleui.types.Point[] texCoords,
                                                 @Nullable
                                                 @org.jetbrains.annotations.Nullable short[] indices,
                                                 @NotNull
                                                 @NotNull BlendMode mode,
                                                 @NotNull
                                                 @NotNull Paint paint)

        Draws a triangle strip mesh, using clip and Matrix.

        If paint contains an Shader and vertices does not contain texCoords, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        texCoords - Point array of texture coordinates, mapping Shader to corners; may be null
        indices - with which indices points should be drawn; may be null
        mode - combines vertices colors with Shader, if both are present
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawTriangleFan

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawTriangleFan​(@NotNull
                                               @NotNull io.github.humbleui.types.Point[] positions,
                                               @Nullable
                                               @org.jetbrains.annotations.Nullable int[] colors,
                                               @NotNull
                                               @NotNull Paint paint)

        Draws a triangle fan mesh, using clip and Matrix.

        If paint contains an Shader, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawTriangleFan

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawTriangleFan​(@NotNull
                                               @NotNull io.github.humbleui.types.Point[] positions,
                                               @Nullable
                                               @org.jetbrains.annotations.Nullable int[] colors,
                                               @Nullable
                                               @Nullable io.github.humbleui.types.Point[] texCoords,
                                               @Nullable
                                               @org.jetbrains.annotations.Nullable short[] indices,
                                               @NotNull
                                               @NotNull Paint paint)

        Draws a triangle fan mesh, using clip and Matrix.

        If paint contains an Shader and vertices does not contain texCoords, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        texCoords - Point array of texture coordinates, mapping Shader to corners; may be null
        indices - with which indices points should be drawn; may be null
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawTriangleFan

        @NotNull
        @Contract("_, _, _, _, _, _ -> this")
        public @NotNull Canvas drawTriangleFan​(@NotNull
                                               @NotNull io.github.humbleui.types.Point[] positions,
                                               @Nullable
                                               @org.jetbrains.annotations.Nullable int[] colors,
                                               @Nullable
                                               @Nullable io.github.humbleui.types.Point[] texCoords,
                                               @Nullable
                                               @org.jetbrains.annotations.Nullable short[] indices,
                                               @NotNull
                                               @NotNull BlendMode mode,
                                               @NotNull
                                               @NotNull Paint paint)

        Draws a triangle fan mesh, using clip and Matrix.

        If paint contains an Shader and vertices does not contain texCoords, the shader is mapped using the vertices' positions.

        If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.

        Parameters:
        positions - triangle mesh to draw
        colors - color array, one for each corner; may be null
        texCoords - Point array of texture coordinates, mapping Shader to corners; may be null
        indices - with which indices points should be drawn; may be null
        mode - combines vertices colors with Shader, if both are present
        paint - specifies the Shader, used as Vertices texture
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawVertices, https://fiddle.skia.org/c/@Canvas_drawVertices_2
      • drawPatch

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawPatch​(@NotNull
                                         @NotNull io.github.humbleui.types.Point[] cubics,
                                         @NotNull
                                         @org.jetbrains.annotations.NotNull int[] colors,
                                         @NotNull
                                         @NotNull Paint paint)

        Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.

        Coons patch uses clip and Matrix, paint Shader, ColorFilter, alpha, ImageFilter, and BlendMode. If Shader is provided it is treated as Coons patch texture.

        Point array cubics specifies four Path cubic starting at the top-left corner, in clockwise order, sharing every fourth point. The last Path cubic ends at the first point.

        Color array color associates colors with corners in top-left, top-right, bottom-right, bottom-left order.

        Parameters:
        cubics - Path cubic array, sharing common points
        colors - color array, one for each corner
        paint - Shader, ColorFilter, BlendMode, used to draw
        Returns:
        this
        See Also:
        https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445
      • drawPatch

        @NotNull
        @Contract("_, _, _, _ -> this")
        public @NotNull Canvas drawPatch​(@NotNull
                                         @NotNull io.github.humbleui.types.Point[] cubics,
                                         @NotNull
                                         @org.jetbrains.annotations.NotNull int[] colors,
                                         @Nullable
                                         @Nullable io.github.humbleui.types.Point[] texCoords,
                                         @NotNull
                                         @NotNull Paint paint)

        Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.

        Coons patch uses clip and Matrix, paint Shader, ColorFilter, alpha, ImageFilter, and BlendMode. If Shader is provided it is treated as Coons patch texture.

        Point array cubics specifies four Path cubic starting at the top-left corner, in clockwise order, sharing every fourth point. The last Path cubic ends at the first point.

        Color array color associates colors with corners in top-left, top-right, bottom-right, bottom-left order.

        If paint contains Shader, Point array texCoords maps Shader as texture to corners in top-left, top-right, bottom-right, bottom-left order. If texCoords is nullptr, Shader is mapped using positions (derived from cubics).

        Parameters:
        cubics - Path cubic array, sharing common points
        colors - color array, one for each corner
        texCoords - Point array of texture coordinates, mapping Shader to corners; may be null
        paint - Shader, ColorFilter, BlendMode, used to draw
        Returns:
        this
        See Also:
        https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445
      • drawPatch

        @NotNull
        @Contract("_, _, _, _, _ -> this")
        public @NotNull Canvas drawPatch​(@NotNull
                                         @NotNull io.github.humbleui.types.Point[] cubics,
                                         @NotNull
                                         @org.jetbrains.annotations.NotNull int[] colors,
                                         @Nullable
                                         @Nullable io.github.humbleui.types.Point[] texCoords,
                                         @NotNull
                                         @NotNull BlendMode mode,
                                         @NotNull
                                         @NotNull Paint paint)

        Draws a Coons patch: the interpolation of four cubics with shared corners, associating a color, and optionally a texture SkPoint, with each corner.

        Coons patch uses clip and Matrix, paint Shader, ColorFilter, alpha, ImageFilter, and BlendMode. If Shader is provided it is treated as Coons patch texture; BlendMode mode combines color colors and Shader if both are provided.

        Point array cubics specifies four Path cubic starting at the top-left corner, in clockwise order, sharing every fourth point. The last Path cubic ends at the first point.

        Color array color associates colors with corners in top-left, top-right, bottom-right, bottom-left order.

        If paint contains Shader, Point array texCoords maps Shader as texture to corners in top-left, top-right, bottom-right, bottom-left order. If texCoords is nullptr, Shader is mapped using positions (derived from cubics).

        Parameters:
        cubics - Path cubic array, sharing common points
        colors - color array, one for each corner
        texCoords - Point array of texture coordinates, mapping Shader to corners; may be null
        mode - BlendMode for colors, and for Shader if paint has one
        paint - Shader, ColorFilter, BlendMode, used to draw
        Returns:
        this
        See Also:
        https://fiddle.skia.org/c/4cf70f8d194867d053d7e177e5088445
      • drawDrawable

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas drawDrawable​(@NotNull
                                            @NotNull Drawable drawable)

        Draws Drawable drawable using clip and matrix.

        If Canvas has an asynchronous implementation, as is the case when it is recording into Picture, then drawable will be referenced, so that Drawable::draw() can be called when the operation is finalized. To force immediate drawing, call Drawable::draw() instead.

        Parameters:
        drawable - custom struct encapsulating drawing commands
        Returns:
        this
      • drawDrawable

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas drawDrawable​(@NotNull
                                            @NotNull Drawable drawable,
                                            float x,
                                            float y)

        Draws Drawable drawable using clip and matrix, offset by (x, y).

        If Canvas has an asynchronous implementation, as is the case when it is recording into Picture, then drawable will be referenced, so that Drawable::draw() can be called when the operation is finalized. To force immediate drawing, call Drawable::draw() instead.

        Parameters:
        drawable - custom struct encapsulating drawing commands
        x - offset into Canvas writable pixels on x-axis
        y - offset into Canvas writable pixels on y-axis
        Returns:
        this
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawDrawable_2
      • drawDrawable

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawDrawable​(@NotNull
                                            @NotNull Drawable drawable,
                                            @Nullable
                                            @Nullable Matrix33 matrix)

        Draws Drawable drawable using clip and matrix, concatenated with optional matrix.

        If Canvas has an asynchronous implementation, as is the case when it is recording into Picture, then drawable will be referenced, so that Drawable::draw() can be called when the operation is finalized. To force immediate drawing, call Drawable::draw() instead.

        Parameters:
        drawable - custom struct encapsulating drawing commands
        matrix - transformation applied to drawing; may be null
        Returns:
        this
        See Also:
        https://fiddle.skia.org/c/@Canvas_drawDrawable
      • drawColor

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas drawColor​(int color)
      • drawColor

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawColor​(int color,
                                         @NotNull
                                         @NotNull BlendMode mode)
      • drawColor

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas drawColor​(@NotNull
                                         @NotNull Color4f color)
      • drawColor

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas drawColor​(@NotNull
                                         @NotNull Color4f color,
                                         @NotNull
                                         @NotNull BlendMode mode)
      • clear

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas clear​(int color)
      • drawPaint

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas drawPaint​(@NotNull
                                         @NotNull Paint paint)
      • setMatrix

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas setMatrix​(@NotNull
                                         @NotNull Matrix33 matrix)
        Replaces Matrix with matrix. Unlike concat(), any prior matrix state is overwritten.
        Parameters:
        matrix - matrix to copy, replacing existing Matrix
        See Also:
        https://fiddle.skia.org/c/@Canvas_setMatrix
      • setMatrix

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas setMatrix​(@NotNull
                                         @NotNull Matrix44 matrix)
        Replaces Matrix with matrix. Unlike concat(), any prior matrix state is overwritten.
        Parameters:
        matrix - matrix to copy, replacing existing Matrix
        See Also:
        https://fiddle.skia.org/c/@Canvas_setMatrix
      • getLocalToDevice

        @NotNull
        @Contract("-> new")
        public @NotNull Matrix44 getLocalToDevice()
        Returns the total transformation matrix for the canvas.
      • getLocalToDeviceAsMatrix33

        @NotNull
        @Contract("-> new")
        public @NotNull Matrix33 getLocalToDeviceAsMatrix33()
      • clipRect

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas clipRect​(@NotNull
                                        @NotNull io.github.humbleui.types.Rect r,
                                        @NotNull
                                        @NotNull ClipMode mode,
                                        boolean antiAlias)
      • clipRect

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas clipRect​(@NotNull
                                        @NotNull io.github.humbleui.types.Rect r,
                                        @NotNull
                                        @NotNull ClipMode mode)
      • clipRect

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas clipRect​(@NotNull
                                        @NotNull io.github.humbleui.types.Rect r,
                                        boolean antiAlias)
      • clipRect

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas clipRect​(@NotNull
                                        @NotNull io.github.humbleui.types.Rect r)
      • clipRRect

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas clipRRect​(@NotNull
                                         @NotNull io.github.humbleui.types.RRect r,
                                         @NotNull
                                         @NotNull ClipMode mode,
                                         boolean antiAlias)
      • clipRRect

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas clipRRect​(@NotNull
                                         @NotNull io.github.humbleui.types.RRect r,
                                         @NotNull
                                         @NotNull ClipMode mode)
      • clipRRect

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas clipRRect​(@NotNull
                                         @NotNull io.github.humbleui.types.RRect r,
                                         boolean antiAlias)
      • clipRRect

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas clipRRect​(@NotNull
                                         @NotNull io.github.humbleui.types.RRect r)
      • clipPath

        @NotNull
        @Contract("_, _, _ -> this")
        public @NotNull Canvas clipPath​(@NotNull
                                        @NotNull Path p,
                                        @NotNull
                                        @NotNull ClipMode mode,
                                        boolean antiAlias)
      • clipPath

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas clipPath​(@NotNull
                                        @NotNull Path p,
                                        @NotNull
                                        @NotNull ClipMode mode)
      • clipPath

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas clipPath​(@NotNull
                                        @NotNull Path p,
                                        boolean antiAlias)
      • clipPath

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas clipPath​(@NotNull
                                        @NotNull Path p)
      • clipRegion

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas clipRegion​(@NotNull
                                          @NotNull Region r,
                                          @NotNull
                                          @NotNull ClipMode mode)
      • clipRegion

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas clipRegion​(@NotNull
                                          @NotNull Region r)
      • translate

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas translate​(float dx,
                                         float dy)
      • scale

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas scale​(float sx,
                                     float sy)
      • rotate

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas rotate​(float deg)
        Parameters:
        deg - angle in degrees
        Returns:
        this
      • skew

        @NotNull
        @Contract("_, _ -> this")
        public @NotNull Canvas skew​(float sx,
                                    float sy)
      • concat

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas concat​(@NotNull
                                      @NotNull Matrix33 matrix)
      • concat

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas concat​(@NotNull
                                      @NotNull Matrix44 matrix)
      • readPixels

        public boolean readPixels​(@NotNull
                                  @NotNull Bitmap bitmap,
                                  int srcX,
                                  int srcY)

        Copies Rect of pixels from Canvas into bitmap. Matrix and clip are ignored.

        Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()). Destination Rect corners are (0, 0) and (bitmap.width(), bitmap.height()). Copies each readable pixel intersecting both rectangles, without scaling, converting to bitmap.colorType() and bitmap.alphaType() if required.

        Pixels are readable when BaseDevice is raster, or backed by a GPU. Pixels are not readable when Canvas is returned by Document::beginPage, returned by PictureRecorder::beginRecording, or Canvas is the base of a utility class like DebugCanvas.

        Caller must allocate pixel storage in bitmap if needed.

        SkBitmap values are converted only if ColorType and AlphaType do not match. Only pixels within both source and destination rectangles are copied. Bitmap pixels outside Rect intersection are unchanged.

        Pass negative values for srcX or srcY to offset pixels across or down bitmap.

        Does not copy, and returns false if:

        • Source and destination rectangles do not intersect.
        • SkCanvas pixels could not be converted to bitmap.colorType() or bitmap.alphaType().
        • SkCanvas pixels are not readable; for instance, Canvas is document-based.
        • bitmap pixels could not be allocated.
        • bitmap.rowBytes() is too small to contain one row of pixels.
        Parameters:
        bitmap - storage for pixels copied from Canvas
        srcX - offset into readable pixels on x-axis; may be negative
        srcY - offset into readable pixels on y-axis; may be negative
        Returns:
        true if pixels were copied
        See Also:
        https://fiddle.skia.org/c/@Canvas_readPixels_3
      • writePixels

        public boolean writePixels​(@NotNull
                                   @NotNull Bitmap bitmap,
                                   int x,
                                   int y)

        Copies Rect from pixels to Canvas. Matrix and clip are ignored. Source Rect corners are (0, 0) and (bitmap.width(), bitmap.height()).

        Destination Rect corners are (x, y) and (imageInfo().width(), imageInfo().height()).

        Copies each readable pixel intersecting both rectangles, without scaling, converting to getImageInfo().getColorType() and getImageInfo().getAlphaType() if required.

        Pixels are writable when BaseDevice is raster, or backed by a GPU. Pixels are not writable when Canvas is returned by Document::beginPage, returned by PictureRecorder::beginRecording, or Canvas is the base of a utility class like DebugCanvas.

        Pixel values are converted only if ColorType and AlphaType do not match. Only pixels within both source and destination rectangles are copied. Canvas pixels outside Rect intersection are unchanged.

        Pass negative values for x or y to offset pixels to the left or above Canvas pixels.

        Does not copy, and returns false if:

        • Source and destination rectangles do not intersect.
        • bitmap does not have allocated pixels.
        • bitmap pixels could not be converted to Canvas getImageInfo().getColorType() or getImageInfo().getAlphaType().
        • Canvas pixels are not writable; for instance, Canvas is document based.
        • bitmap pixels are inaccessible; for instance, bitmap wraps a texture.
        Parameters:
        bitmap - contains pixels copied to Canvas
        x - offset into Canvas writable pixels on x-axis; may be negative
        y - offset into Canvas writable pixels on y-axis; may be negative
        Returns:
        true if pixels were written to Canvas
        See Also:
        https://fiddle.skia.org/c/@Canvas_writePixels_2, https://fiddle.skia.org/c/@State_Stack_a, https://fiddle.skia.org/c/@State_Stack_b
      • save

        public int save()
      • saveLayer

        public int saveLayer​(float left,
                             float top,
                             float right,
                             float bottom,
                             @Nullable
                             @Nullable Paint paint)
      • saveLayer

        public int saveLayer​(@Nullable
                             @Nullable io.github.humbleui.types.Rect bounds,
                             @Nullable
                             @Nullable Paint paint)

        Saves Matrix and clip, and allocates a Bitmap for subsequent drawing. Calling restore() discards changes to Matrix and clip, and draws the Bitmap.

        Matrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().

        Rect bounds suggests but does not define the Bitmap size. To clip drawing to a specific rectangle, use clipRect().

        Optional Paint paint applies alpha, ColorFilter, ImageFilter, and BlendMode when restore() is called.

        Call restoreToCount() with returned value to restore this and subsequent saves.

        Parameters:
        bounds - hint to limit the size of the layer
        paint - graphics state for layer; may be null
        Returns:
        depth of saved stack
        See Also:
        https://fiddle.skia.org/c/@Canvas_saveLayer, https://fiddle.skia.org/c/@Canvas_saveLayer_4
      • saveLayerAlpha

        public int saveLayerAlpha​(@Nullable
                                  @Nullable io.github.humbleui.types.Rect bounds,
                                  int alpha)

        Saves matrix and clip, and allocates bitmap for subsequent drawing.

        Calling restore() discards changes to matrix and clip, and blends layer with alpha opacity onto prior layer.

        matrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().

        Bounds suggests but does not define layer size. To clip drawing to a specific rectangle, use clipRect().

        Call restoreToCount() with returned value to restore this and subsequent saves.

        Parameters:
        bounds - hint to limit the size of layer; may be null
        alpha - opacity of layer, zero is fully transparent, 255 is fully opaque.
        Returns:
        depth of saved stack
        See Also:
        https://fiddle.skia.org/c/@Canvas_saveLayerAlpha
      • saveLayer

        public int saveLayer​(@NotNull
                             @NotNull SaveLayerRec layerRec)

        Saves matrix and clip, and allocates Bitmap for subsequent drawing.

        Calling restore() discards changes to matrix and clip, and blends Bitmap with alpha opacity onto the prior layer.

        matrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().

        SaveLayerRec contains the state used to create the layer.

        Call restoreToCount() with returned value to restore this and subsequent saves.

        Parameters:
        layerRec - layer state
        Returns:
        depth of save state stack before this call was made.
        See Also:
        https://fiddle.skia.org/c/@Canvas_saveLayer_3
      • getSaveCount

        public int getSaveCount()
      • restore

        @NotNull
        @Contract("-> this")
        public @NotNull Canvas restore()
      • restoreToCount

        @NotNull
        @Contract("_ -> this")
        public @NotNull Canvas restoreToCount​(int saveCount)
      • _nGetFinalizer

        public static long _nGetFinalizer()
      • _nMakeFromBitmap

        public static long _nMakeFromBitmap​(long bitmapPtr,
                                            int flags,
                                            int pixelGeometry)
      • _nGetBaseProps

        public static SurfaceProps _nGetBaseProps​(long ptr)
      • _nGetTopProps

        public static SurfaceProps _nGetTopProps​(long ptr)
      • _nGetSurface

        public static long _nGetSurface​(long ptr)
      • _nDrawPoint

        public static void _nDrawPoint​(long ptr,
                                       float x,
                                       float y,
                                       long paintPtr)
      • _nDrawPoints

        public static void _nDrawPoints​(long ptr,
                                        int mode,
                                        float[] coords,
                                        long paintPtr)
      • _nDrawLine

        public static void _nDrawLine​(long ptr,
                                      float x0,
                                      float y0,
                                      float x1,
                                      float y1,
                                      long paintPtr)
      • _nDrawArc

        public static void _nDrawArc​(long ptr,
                                     float left,
                                     float top,
                                     float right,
                                     float bottom,
                                     float startAngle,
                                     float sweepAngle,
                                     boolean includeCenter,
                                     long paintPtr)
      • _nDrawRect

        public static void _nDrawRect​(long ptr,
                                      float left,
                                      float top,
                                      float right,
                                      float bottom,
                                      long paintPtr)
      • _nDrawOval

        public static void _nDrawOval​(long ptr,
                                      float left,
                                      float top,
                                      float right,
                                      float bottom,
                                      long paint)
      • _nDrawRRect

        public static void _nDrawRRect​(long ptr,
                                       float left,
                                       float top,
                                       float right,
                                       float bottom,
                                       float[] radii,
                                       long paintPtr)
      • _nQuickReject

        public static boolean _nQuickReject​(long ptr,
                                            float left,
                                            float top,
                                            float right,
                                            float bottom)
      • _nQuickRejectPath

        public static boolean _nQuickRejectPath​(long ptr,
                                                long pathPtr)
      • _nDrawDRRect

        public static void _nDrawDRRect​(long ptr,
                                        float ol,
                                        float ot,
                                        float or,
                                        float ob,
                                        float[] oradii,
                                        float il,
                                        float it,
                                        float ir,
                                        float ib,
                                        float[] iradii,
                                        long paintPtr)
      • _nDrawPath

        public static void _nDrawPath​(long ptr,
                                      long nativePath,
                                      long paintPtr)
      • _nDrawImageRect

        public static void _nDrawImageRect​(long ptr,
                                           long nativeImage,
                                           float sl,
                                           float st,
                                           float sr,
                                           float sb,
                                           float dl,
                                           float dt,
                                           float dr,
                                           float db,
                                           long samplingMode,
                                           long paintPtr,
                                           boolean strict)
      • _nDrawImageNine

        public static void _nDrawImageNine​(long ptr,
                                           long nativeImage,
                                           int cl,
                                           int ct,
                                           int cr,
                                           int cb,
                                           float dl,
                                           float dt,
                                           float dr,
                                           float db,
                                           int filterMode,
                                           long paintPtr)
      • _nDrawRegion

        public static void _nDrawRegion​(long ptr,
                                        long nativeRegion,
                                        long paintPtr)
      • _nDrawString

        public static void _nDrawString​(long ptr,
                                        java.lang.String string,
                                        float x,
                                        float y,
                                        long font,
                                        long paint)
      • _nDrawTextBlob

        public static void _nDrawTextBlob​(long ptr,
                                          long blob,
                                          float x,
                                          float y,
                                          long paint)
      • _nDrawPicture

        public static void _nDrawPicture​(long ptr,
                                         long picturePtr,
                                         float[] matrix,
                                         long paintPtr)
      • _nDrawVertices

        public static void _nDrawVertices​(long ptr,
                                          int verticesMode,
                                          float[] cubics,
                                          int[] colors,
                                          float[] texCoords,
                                          short[] indices,
                                          int blendMode,
                                          long paintPtr)
      • _nDrawPatch

        public static void _nDrawPatch​(long ptr,
                                       float[] cubics,
                                       int[] colors,
                                       float[] texCoords,
                                       int blendMode,
                                       long paintPtr)
      • _nDrawDrawable

        public static void _nDrawDrawable​(long ptr,
                                          long drawablePrt,
                                          float[] matrix)
      • _nDrawColor

        public static void _nDrawColor​(long ptr,
                                       int color,
                                       int blendMode)
      • _nDrawColor4f

        public static void _nDrawColor4f​(long ptr,
                                         float r,
                                         float g,
                                         float b,
                                         float a,
                                         int blendMode)
      • _nClear

        public static void _nClear​(long ptr,
                                   int color)
      • _nDrawPaint

        public static void _nDrawPaint​(long ptr,
                                       long paintPtr)
      • _nSetMatrix

        public static void _nSetMatrix​(long ptr,
                                       float[] matrix)
      • _nSetMatrix44

        public static void _nSetMatrix44​(long ptr,
                                         float[] matrix)
      • _nGetLocalToDevice

        public static float[] _nGetLocalToDevice​(long ptr)
      • _nResetMatrix

        public static void _nResetMatrix​(long ptr)
      • _nClipRect

        public static void _nClipRect​(long ptr,
                                      float left,
                                      float top,
                                      float right,
                                      float bottom,
                                      int mode,
                                      boolean antiAlias)
      • _nClipRRect

        public static void _nClipRRect​(long ptr,
                                       float left,
                                       float top,
                                       float right,
                                       float bottom,
                                       float[] radii,
                                       int mode,
                                       boolean antiAlias)
      • _nClipPath

        public static void _nClipPath​(long ptr,
                                      long nativePath,
                                      int mode,
                                      boolean antiAlias)
      • _nClipRegion

        public static void _nClipRegion​(long ptr,
                                        long nativeRegion,
                                        int mode)
      • _nConcat

        public static void _nConcat​(long ptr,
                                    float[] matrix)
      • _nConcat44

        public static void _nConcat44​(long ptr,
                                      float[] matrix)
      • _nReadPixels

        public static boolean _nReadPixels​(long ptr,
                                           long bitmapPtr,
                                           int srcX,
                                           int srcY)
      • _nWritePixels

        public static boolean _nWritePixels​(long ptr,
                                            long bitmapPtr,
                                            int x,
                                            int y)
      • _nSave

        public static int _nSave​(long ptr)
      • _nSaveLayer

        public static int _nSaveLayer​(long ptr,
                                      long paintPtr)
      • _nSaveLayerRect

        public static int _nSaveLayerRect​(long ptr,
                                          float left,
                                          float top,
                                          float right,
                                          float bottom,
                                          long paintPtr)
      • _nSaveLayerAlpha

        public static int _nSaveLayerAlpha​(long ptr,
                                           int alpha)
      • _nSaveLayerAlphaRect

        public static int _nSaveLayerAlphaRect​(long ptr,
                                               float left,
                                               float top,
                                               float right,
                                               float bottom,
                                               int alpha)
      • _nSaveLayerRec

        public static int _nSaveLayerRec​(long ptr,
                                         long paintPtr,
                                         long backdropPtr,
                                         int flags)
      • _nSaveLayerRecRect

        public static int _nSaveLayerRecRect​(long ptr,
                                             float left,
                                             float top,
                                             float right,
                                             float bottom,
                                             long paintPtr,
                                             long backdropPtr,
                                             int flags)
      • _nGetSaveCount

        public static int _nGetSaveCount​(long ptr)
      • _nRestore

        public static void _nRestore​(long ptr)
      • _nRestoreToCount

        public static void _nRestoreToCount​(long ptr,
                                            int saveCount)