Class Paint

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Paint
    extends Managed
    • Method Detail

      • makeClone

        @NotNull
        @Contract("-> new")
        public @NotNull Paint makeClone()

        Makes a shallow copy of Paint. PathEffect, Shader, MaskFilter, ColorFilter, and ImageFilter are shared between the original paint and the copy.

        The referenced objects PathEffect, Shader, MaskFilter, ColorFilter, and ImageFilter cannot be modified after they are created.

        Returns:
        shallow copy of paint
        See Also:
        https://fiddle.skia.org/c/@Paint_copy_const_SkPaint
      • reset

        @NotNull
        @Contract("-> this")
        public @NotNull Paint reset()
        Sets all Paint contents to their initial values. This is equivalent to replacing Paint with the result of Paint().
        See Also:
        https://fiddle.skia.org/c/@Paint_reset
      • isAntiAlias

        public boolean isAntiAlias()
        Returns true if pixels on the active edges of Path may be drawn with partial transparency.
        Returns:
        antialiasing state
      • setAntiAlias

        @NotNull
        @Contract("_ -> this")
        public @NotNull Paint setAntiAlias​(boolean value)
        Requests, but does not require, that edge pixels draw opaque or with partial transparency.
        Parameters:
        value - setting for antialiasing
      • isDither

        public boolean isDither()
        Returns:
        true if color error may be distributed to smooth color transition.
      • setDither

        @NotNull
        @Contract("_ -> this")
        public @NotNull Paint setDither​(boolean value)
        Requests, but does not require, to distribute color error.
        Parameters:
        value - setting for ditering
        Returns:
        this
      • getMode

        @NotNull
        public @NotNull PaintMode getMode()
        Returns:
        whether the geometry is filled, stroked, or filled and stroked.
      • setStroke

        @NotNull
        @Contract("_ -> this")
        public @NotNull Paint setStroke​(boolean value)
        Set paint's mode to STROKE if true, or FILL if false.
        Parameters:
        value - stroke or fill
        Returns:
        this
      • getColor4f

        @NotNull
        public @NotNull Color4f getColor4f()
        Retrieves alpha and RGB, unpremultiplied, as four floating point values. RGB are extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).
        Returns:
        unpremultiplied RGBA
      • setColor

        @NotNull
        @Contract("_ -> this")
        public @NotNull Paint setColor​(int color)
        Sets alpha and RGB used when stroking and filling. The color is a 32-bit value, unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
        Parameters:
        color - unpremultiplied ARGB
        See Also:
        https://fiddle.skia.org/c/@Paint_setColor
      • setColor4f

        @NotNull
        @Contract("!null -> this; null -> fail")
        public @NotNull Paint setColor4f​(@NotNull
                                         @NotNull Color4f color)
        Sets alpha and RGB used when stroking and filling. The color is four floating point values, unpremultiplied. The color values are interpreted as being in sRGB.
        Parameters:
        color - unpremultiplied RGBA
        Returns:
        this
      • setColor4f

        @NotNull
        @Contract("!null, _ -> this; null, _ -> fail")
        public @NotNull Paint setColor4f​(@NotNull
                                         @NotNull Color4f color,
                                         @Nullable
                                         @Nullable ColorSpace colorSpace)
        Sets alpha and RGB used when stroking and filling. The color is four floating point values, unpremultiplied. The color values are interpreted as being in the colorSpace. If colorSpace is nullptr, then color is assumed to be in the sRGB color space.
        Parameters:
        color - unpremultiplied RGBA
        colorSpace - SkColorSpace describing the encoding of color
        Returns:
        this
      • getAlphaf

        public float getAlphaf()
        Retrieves alpha from the color used when stroking and filling.
        Returns:
        alpha ranging from 0f, fully transparent, to 1f, fully opaque
      • getAlpha

        public int getAlpha()
        Retrieves alpha from the color used when stroking and filling.
        Returns:
        alpha ranging from 0, fully transparent, to 255, fully opaque
      • setAlphaf

        @NotNull
        @Contract("_ -> this")
        public @NotNull Paint setAlphaf​(float a)

        Replaces alpha, leaving RGB unchanged. An out of range value triggers an assert in the debug build. a is a value from 0f to 1f.

        a set to zero makes color fully transparent; a set to 1.0 makes color fully opaque.

        Parameters:
        a - alpha component of color
        Returns:
        this
      • setAlpha

        @NotNull
        @Contract("_ -> this")
        public @NotNull Paint setAlpha​(int a)

        Replaces alpha, leaving RGB unchanged. An out of range value triggers an assert in the debug build. a is a value from 0 to 255.

        a set to zero makes color fully transparent; a set to 255 makes color fully opaque.

        Parameters:
        a - alpha component of color
        Returns:
        this
      • setARGB

        @NotNull
        @Contract("_, _, _, _ -> this")
        public @NotNull Paint setARGB​(int a,
                                      int r,
                                      int g,
                                      int b)
        Sets color used when drawing solid fills. The color components range from 0 to 255. The color is unpremultiplied; alpha sets the transparency independent of RGB.
        Parameters:
        a - amount of alpha, from fully transparent (0) to fully opaque (255)
        r - amount of red, from no red (0) to full red (255)
        g - amount of green, from no green (0) to full green (255)
        b - amount of blue, from no blue (0) to full blue (255)
        See Also:
        https://fiddle.skia.org/c/@Paint_setARGB
      • getStrokeWidth

        public float getStrokeWidth()
        Returns the thickness of the pen used by Paint to outline the shape.
        Returns:
        zero for hairline, greater than zero for pen thickness
      • setStrokeWidth

        @NotNull
        @Contract("_ -> this")
        public @NotNull Paint setStrokeWidth​(float width)
        Sets the thickness of the pen used by the paint to outline the shape. A stroke-width of zero is treated as "hairline" width. Hairlines are always exactly one pixel wide in device space (their thickness does not change as the canvas is scaled). Negative stroke-widths are invalid; setting a negative width will have no effect.
        Parameters:
        width - zero thickness for hairline; greater than zero for pen thickness
        See Also:
        https://fiddle.skia.org/c/@Miter_Limit, https://fiddle.skia.org/c/@Paint_setStrokeWidth
      • getStrokeMiter

        public float getStrokeMiter()
        Returns the limit at which a sharp corner is drawn beveled.
        Returns:
        zero and greater miter limit
      • setStrokeMiter

        @NotNull
        @Contract("_ -> this")
        public @NotNull Paint setStrokeMiter​(float miter)
        Sets the limit at which a sharp corner is drawn beveled. Valid values are zero and greater. Has no effect if miter is less than zero.
        Parameters:
        miter - zero and greater miter limit
        Returns:
        this
        See Also:
        https://fiddle.skia.org/c/@Paint_setStrokeMiter
      • getStrokeCap

        @NotNull
        @Contract("-> this")
        public @NotNull PaintStrokeCap getStrokeCap()
        Returns:
        the geometry drawn at the beginning and end of strokes.
      • getStrokeJoin

        @NotNull
        @Contract("-> this")
        public @NotNull PaintStrokeJoin getStrokeJoin()
        Returns:
        the geometry drawn at the corners of strokes.
      • getFillPath

        @NotNull
        @Contract("!null -> new; null -> fail")
        public @NotNull Path getFillPath​(@NotNull
                                         @NotNull Path src)
        Returns the filled equivalent of the stroked path.
        Parameters:
        src - Path read to create a filled version
        Returns:
        resulting Path
      • getFillPath

        @NotNull
        @Contract("!null, _, _ -> new; null, _, _ -> fail")
        public @NotNull Path getFillPath​(@NotNull
                                         @NotNull Path src,
                                         @Nullable
                                         @Nullable io.github.humbleui.types.Rect cull,
                                         float resScale)
        Returns the filled equivalent of the stroked path.
        Parameters:
        src - Path read to create a filled version
        cull - Optional limit passed to PathEffect
        resScale - if > 1, increase precision, else if (0 < resScale < 1) reduce precision to favor speed and size
        Returns:
        resulting Path
      • getBlendMode

        @Nullable
        public @Nullable BlendMode getBlendMode()
        Returns BlendMode. By default, returns BlendMode.SRC_OVER.
        Returns:
        mode used to combine source color with destination color
      • isSrcOver

        public boolean isSrcOver()
        Returns:
        true if BlendMode is BlendMode.SRC_OVER, the default.
      • setBlendMode

        @NotNull
        @Contract("!null -> this; null -> fail")
        public @NotNull Paint setBlendMode​(@NotNull
                                           @NotNull BlendMode mode)
        Sets SkBlendMode to mode. Does not check for valid input.
        Parameters:
        mode - BlendMode used to combine source color and destination
        Returns:
        this
      • hasNothingToDraw

        public boolean hasNothingToDraw()

        Returns true if Paint prevents all drawing; otherwise, the Paint may or may not allow drawing.

        Returns true if, for example, BlendMode combined with alpha computes a new alpha of zero.

        Returns:
        true if Paint prevents all drawing
        See Also:
        https://fiddle.skia.org/c/@Paint_nothingToDraw
      • _nGetFinalizer

        public static long _nGetFinalizer()
      • _nMake

        public static long _nMake()
      • _nMakeClone

        public static long _nMakeClone​(long ptr)
      • _nEquals

        public static boolean _nEquals​(long ptr,
                                       long otherPtr)
      • _nReset

        public static void _nReset​(long ptr)
      • _nIsAntiAlias

        public static boolean _nIsAntiAlias​(long ptr)
      • _nSetAntiAlias

        public static void _nSetAntiAlias​(long ptr,
                                          boolean value)
      • _nIsDither

        public static boolean _nIsDither​(long ptr)
      • _nSetDither

        public static void _nSetDither​(long ptr,
                                       boolean value)
      • _nGetMode

        public static int _nGetMode​(long ptr)
      • _nSetMode

        public static void _nSetMode​(long ptr,
                                     int value)
      • _nGetColor

        public static int _nGetColor​(long ptr)
      • _nGetColor4f

        public static Color4f _nGetColor4f​(long ptr)
      • _nSetColor

        public static void _nSetColor​(long ptr,
                                      int argb)
      • _nSetColor4f

        public static void _nSetColor4f​(long ptr,
                                        float r,
                                        float g,
                                        float b,
                                        float a,
                                        long colorSpacePtr)
      • _nGetStrokeWidth

        public static float _nGetStrokeWidth​(long ptr)
      • _nSetStrokeWidth

        public static void _nSetStrokeWidth​(long ptr,
                                            float value)
      • _nGetStrokeMiter

        public static float _nGetStrokeMiter​(long ptr)
      • _nSetStrokeMiter

        public static void _nSetStrokeMiter​(long ptr,
                                            float value)
      • _nGetStrokeCap

        public static int _nGetStrokeCap​(long ptr)
      • _nSetStrokeCap

        public static void _nSetStrokeCap​(long ptr,
                                          int value)
      • _nGetStrokeJoin

        public static int _nGetStrokeJoin​(long ptr)
      • _nSetStrokeJoin

        public static void _nSetStrokeJoin​(long ptr,
                                           int value)
      • _nGetFillPath

        public static long _nGetFillPath​(long ptr,
                                         long path,
                                         float resScale)
      • _nGetFillPathCull

        public static long _nGetFillPathCull​(long ptr,
                                             long path,
                                             float left,
                                             float top,
                                             float right,
                                             float bottom,
                                             float resScale)
      • _nGetShader

        public static long _nGetShader​(long ptr)
      • _nSetShader

        public static void _nSetShader​(long ptr,
                                       long shaderPtr)
      • _nGetColorFilter

        public static long _nGetColorFilter​(long ptr)
      • _nSetColorFilter

        public static void _nSetColorFilter​(long ptr,
                                            long colorFilterPtr)
      • _nGetBlendMode

        public static int _nGetBlendMode​(long ptr)
      • _nSetBlendMode

        public static void _nSetBlendMode​(long ptr,
                                          int mode)
      • _nGetPathEffect

        public static long _nGetPathEffect​(long ptr)
      • _nSetPathEffect

        public static void _nSetPathEffect​(long ptr,
                                           long pathEffectPtr)
      • _nGetMaskFilter

        public static long _nGetMaskFilter​(long ptr)
      • _nSetMaskFilter

        public static void _nSetMaskFilter​(long ptr,
                                           long filterPtr)
      • _nGetImageFilter

        public static long _nGetImageFilter​(long ptr)
      • _nSetImageFilter

        public static void _nSetImageFilter​(long ptr,
                                            long filterPtr)
      • _nHasNothingToDraw

        public static boolean _nHasNothingToDraw​(long ptr)