Class Paint
- java.lang.Object
-
- io.github.humbleui.skija.impl.Native
-
- io.github.humbleui.skija.impl.Managed
-
- io.github.humbleui.skija.Paint
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Paint extends Managed
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPaint._FinalizerHolder-
Nested classes/interfaces inherited from class io.github.humbleui.skija.impl.Managed
Managed.CleanerThunk
-
-
Field Summary
-
Fields inherited from class io.github.humbleui.skija.impl.Managed
_cleanable
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean_nativeEquals(Native other)static boolean_nEquals(long ptr, long otherPtr)static int_nGetBlendMode(long ptr)static int_nGetColor(long ptr)static Color4f_nGetColor4f(long ptr)static long_nGetColorFilter(long ptr)static long_nGetFillPath(long ptr, long path, float resScale)static long_nGetFillPathCull(long ptr, long path, float left, float top, float right, float bottom, float resScale)static long_nGetFinalizer()static long_nGetImageFilter(long ptr)static long_nGetMaskFilter(long ptr)static int_nGetMode(long ptr)static long_nGetPathEffect(long ptr)static long_nGetShader(long ptr)static int_nGetStrokeCap(long ptr)static int_nGetStrokeJoin(long ptr)static float_nGetStrokeMiter(long ptr)static float_nGetStrokeWidth(long ptr)static boolean_nHasNothingToDraw(long ptr)static boolean_nIsAntiAlias(long ptr)static boolean_nIsDither(long ptr)static long_nMake()static long_nMakeClone(long ptr)static void_nReset(long ptr)static void_nSetAntiAlias(long ptr, boolean value)static void_nSetBlendMode(long ptr, int mode)static void_nSetColor(long ptr, int argb)static void_nSetColor4f(long ptr, float r, float g, float b, float a, long colorSpacePtr)static void_nSetColorFilter(long ptr, long colorFilterPtr)static void_nSetDither(long ptr, boolean value)static void_nSetImageFilter(long ptr, long filterPtr)static void_nSetMaskFilter(long ptr, long filterPtr)static void_nSetMode(long ptr, int value)static void_nSetPathEffect(long ptr, long pathEffectPtr)static void_nSetShader(long ptr, long shaderPtr)static void_nSetStrokeCap(long ptr, int value)static void_nSetStrokeJoin(long ptr, int value)static void_nSetStrokeMiter(long ptr, float value)static void_nSetStrokeWidth(long ptr, float value)intgetAlpha()Retrieves alpha from the color used when stroking and filling.floatgetAlphaf()Retrieves alpha from the color used when stroking and filling.@Nullable BlendModegetBlendMode()Returns BlendMode.intgetColor()Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.@NotNull Color4fgetColor4f()Retrieves alpha and RGB, unpremultiplied, as four floating point values.@Nullable ColorFiltergetColorFilter()@NotNull PathgetFillPath(@NotNull Path src)Returns the filled equivalent of the stroked path.@NotNull PathgetFillPath(@NotNull Path src, @Nullable io.github.humbleui.types.Rect cull, float resScale)Returns the filled equivalent of the stroked path.@Nullable ImageFiltergetImageFilter()@Nullable MaskFiltergetMaskFilter()@NotNull PaintModegetMode()@Nullable PathEffectgetPathEffect()@Nullable ShadergetShader()@NotNull PaintStrokeCapgetStrokeCap()@NotNull PaintStrokeJoingetStrokeJoin()floatgetStrokeMiter()Returns the limit at which a sharp corner is drawn beveled.floatgetStrokeWidth()Returns the thickness of the pen used by Paint to outline the shape.booleanhasNothingToDraw()Returns true if Paint prevents all drawing; otherwise, the Paint may or may not allow drawing.booleanisAntiAlias()Returns true if pixels on the active edges of Path may be drawn with partial transparency.booleanisDither()booleanisSrcOver()@NotNull PaintmakeClone()Makes a shallow copy of Paint.@NotNull Paintreset()Sets all Paint contents to their initial values.@NotNull PaintsetAlpha(int a)Replaces alpha, leaving RGB unchanged.@NotNull PaintsetAlphaf(float a)Replaces alpha, leaving RGB unchanged.@NotNull PaintsetAntiAlias(boolean value)Requests, but does not require, that edge pixels draw opaque or with partial transparency.@NotNull PaintsetARGB(int a, int r, int g, int b)Sets color used when drawing solid fills.@NotNull PaintsetBlendMode(@NotNull BlendMode mode)Sets SkBlendMode to mode.@NotNull PaintsetColor(int color)Sets alpha and RGB used when stroking and filling.@NotNull PaintsetColor4f(@NotNull Color4f color)Sets alpha and RGB used when stroking and filling.@NotNull PaintsetColor4f(@NotNull Color4f color, @Nullable ColorSpace colorSpace)Sets alpha and RGB used when stroking and filling.@NotNull PaintsetColorFilter(@Nullable ColorFilter colorFilter)@NotNull PaintsetDither(boolean value)Requests, but does not require, to distribute color error.@NotNull PaintsetImageFilter(@Nullable ImageFilter imageFilter)@NotNull PaintsetMaskFilter(@Nullable MaskFilter maskFilter)@NotNull PaintsetMode(@NotNull PaintMode style)Sets whether the geometry is filled, stroked, or filled and stroked.@NotNull PaintsetPathEffect(@Nullable PathEffect p)@NotNull PaintsetShader(@Nullable Shader shader)@NotNull PaintsetStroke(boolean value)Set paint's mode to STROKE if true, or FILL if false.@NotNull PaintsetStrokeCap(@NotNull PaintStrokeCap cap)Sets the geometry drawn at the beginning and end of strokes.@NotNull PaintsetStrokeJoin(@NotNull PaintStrokeJoin join)Sets the geometry drawn at the corners of strokes.@NotNull PaintsetStrokeMiter(float miter)Sets the limit at which a sharp corner is drawn beveled.@NotNull PaintsetStrokeWidth(float width)Sets the thickness of the pen used by the paint to outline the shape.-
Methods inherited from class io.github.humbleui.skija.impl.Managed
_nInvokeFinalizer, close, isClosed
-
-
-
-
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
-
_nativeEquals
@Internal public boolean _nativeEquals(Native other)
- Overrides:
_nativeEqualsin classNative
-
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.
-
setMode
@NotNull @Contract("!null -> this; null -> fail") public @NotNull Paint setMode(@NotNull @NotNull PaintMode style)Sets 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
-
getColor
public int getColor()
Retrieves alpha and RGB, unpremultiplied, packed into 32 bits. Use helpersColor.getA(int),Color.getR(int),Color.getG(int), andColor.getB(int)to extract a color component.- Returns:
- unpremultiplied ARGB
-
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 RGBAcolorSpace- 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.
-
setStrokeCap
@NotNull @Contract("!null -> this; null -> fail") public @NotNull Paint setStrokeCap(@NotNull @NotNull PaintStrokeCap cap)Sets the geometry drawn at the beginning and end of strokes.- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Paint_setStrokeCap_a, https://fiddle.skia.org/c/@Paint_setStrokeCap_b
-
getStrokeJoin
@NotNull @Contract("-> this") public @NotNull PaintStrokeJoin getStrokeJoin()- Returns:
- the geometry drawn at the corners of strokes.
-
setStrokeJoin
@NotNull @Contract("!null -> this; null -> fail") public @NotNull Paint setStrokeJoin(@NotNull @NotNull PaintStrokeJoin join)Sets the geometry drawn at the corners of strokes.- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Paint_setStrokeJoin
-
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 versioncull- Optional limit passed to PathEffectresScale- if > 1, increase precision, else if (0 < resScale < 1) reduce precision to favor speed and size- Returns:
- resulting Path
-
getShader
@Nullable public @Nullable Shader getShader()
- Returns:
Shaderor null- See Also:
- https://fiddle.skia.org/c/@Paint_refShader
-
setShader
@NotNull @Contract("_ -> this") public @NotNull Paint setShader(@Nullable @Nullable Shader shader)- Parameters:
shader- how geometry is filled with color; if null, color is used instead- See Also:
- https://fiddle.skia.org/c/@Color_Filter_Methods, https://fiddle.skia.org/c/@Paint_setShader
-
getColorFilter
@Nullable public @Nullable ColorFilter getColorFilter()
- Returns:
ColorFilteror null- See Also:
- https://fiddle.skia.org/c/@Paint_refColorFilter
-
setColorFilter
@NotNull @Contract("_ -> this") public @NotNull Paint setColorFilter(@Nullable @Nullable ColorFilter colorFilter)- Parameters:
colorFilter-ColorFilterto apply to subsequent draw- See Also:
- https://fiddle.skia.org/c/@Blend_Mode_Methods, https://fiddle.skia.org/c/@Paint_setColorFilter
-
getBlendMode
@Nullable public @Nullable BlendMode getBlendMode()
Returns BlendMode. By default, returnsBlendMode.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
-
getPathEffect
@Nullable public @Nullable PathEffect getPathEffect()
- Returns:
PathEffector null- See Also:
- https://fiddle.skia.org/c/@Paint_refPathEffect
-
setPathEffect
@NotNull @Contract("_ -> this") public @NotNull Paint setPathEffect(@Nullable @Nullable PathEffect p)- Parameters:
p- replacePathwith a modification when drawn- See Also:
- https://fiddle.skia.org/c/@Mask_Filter_Methods, https://fiddle.skia.org/c/@Paint_setPathEffect
-
getMaskFilter
@Nullable public @Nullable MaskFilter getMaskFilter()
- Returns:
MaskFilterif previously set, null otherwise- See Also:
- https://fiddle.skia.org/c/@Paint_refMaskFilter
-
setMaskFilter
@NotNull @Contract("_ -> this") public @NotNull Paint setMaskFilter(@Nullable @Nullable MaskFilter maskFilter)- Parameters:
maskFilter- modifies clipping mask generated from drawn geometry- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Paint_setMaskFilter, https://fiddle.skia.org/c/@Typeface_Methods
-
getImageFilter
@Nullable public @Nullable ImageFilter getImageFilter()
- Returns:
ImageFilteror null- See Also:
- https://fiddle.skia.org/c/@Paint_refImageFilter
-
setImageFilter
@NotNull @Contract("_ -> this") public @NotNull Paint setImageFilter(@Nullable @Nullable ImageFilter imageFilter)- Parameters:
imageFilter- how SkImage is sampled when transformed- See Also:
- https://fiddle.skia.org/c/@Draw_Looper_Methods, https://fiddle.skia.org/c/@Paint_setImageFilter
-
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)
-
-