Skia
2D Graphics Library
SkPaint Class Reference

#include <SkPaint.h>

Public Types

enum  Style : uint8_t { kFill_Style, kStroke_Style, kStrokeAndFill_Style }
 
enum  Cap {
  kButt_Cap, kRound_Cap, kSquare_Cap, kLast_Cap = kSquare_Cap,
  kDefault_Cap = kButt_Cap
}
 
enum  Join : uint8_t {
  kMiter_Join, kRound_Join, kBevel_Join, kLast_Join = kBevel_Join,
  kDefault_Join = kMiter_Join
}
 

Public Member Functions

 SkPaint ()
 Constructs SkPaint with default values. More...
 
 SkPaint (const SkColor4f &color, SkColorSpace *colorSpace=nullptr)
 Constructs SkPaint with default values and the given color. More...
 
 SkPaint (const SkPaint &paint)
 Makes a shallow copy of SkPaint. More...
 
 SkPaint (SkPaint &&paint)
 Implements a move constructor to avoid increasing the reference counts of objects referenced by the paint. More...
 
 ~SkPaint ()
 Decreases SkPaint SkRefCnt of owned objects: SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, and SkImageFilter. More...
 
SkPaintoperator= (const SkPaint &paint)
 Makes a shallow copy of SkPaint. More...
 
SkPaintoperator= (SkPaint &&paint)
 Moves the paint to avoid increasing the reference counts of objects referenced by the paint parameter. More...
 
uint32_t getHash () const
 Returns a hash generated from SkPaint values and pointers. More...
 
void reset ()
 Sets all SkPaint contents to their initial values. More...
 
bool isAntiAlias () const
 Returns true if pixels on the active edges of SkPath may be drawn with partial transparency. More...
 
void setAntiAlias (bool aa)
 Requests, but does not require, that edge pixels draw opaque or with partial transparency. More...
 
bool isDither () const
 Returns true if color error may be distributed to smooth color transition. More...
 
void setDither (bool dither)
 Requests, but does not require, to distribute color error. More...
 
SkFilterQuality getFilterQuality () const
 Returns SkFilterQuality, the image filtering level. More...
 
void setFilterQuality (SkFilterQuality quality)
 Sets SkFilterQuality, the image filtering level. More...
 
Style getStyle () const
 Returns whether the geometry is filled, stroked, or filled and stroked. More...
 
void setStyle (Style style)
 Sets whether the geometry is filled, stroked, or filled and stroked. More...
 
void setStroke (bool)
 Set paint's style to kStroke if true, or kFill if false. More...
 
SkColor getColor () const
 Retrieves alpha and RGB, unpremultiplied, packed into 32 bits. More...
 
SkColor4f getColor4f () const
 Retrieves alpha and RGB, unpremultiplied, as four floating point values. More...
 
void setColor (SkColor color)
 Sets alpha and RGB used when stroking and filling. More...
 
void setColor (const SkColor4f &color, SkColorSpace *colorSpace=nullptr)
 Sets alpha and RGB used when stroking and filling. More...
 
void setColor4f (const SkColor4f &color, SkColorSpace *colorSpace=nullptr)
 
float getAlphaf () const
 Retrieves alpha from the color used when stroking and filling. More...
 
uint8_t getAlpha () const
 
void setAlphaf (float a)
 Replaces alpha, leaving RGB unchanged. More...
 
void setAlpha (U8CPU a)
 
void setARGB (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 Sets color used when drawing solid fills. More...
 
SkScalar getStrokeWidth () const
 Returns the thickness of the pen used by SkPaint to outline the shape. More...
 
void setStrokeWidth (SkScalar width)
 Sets the thickness of the pen used by the paint to outline the shape. More...
 
SkScalar getStrokeMiter () const
 Returns the limit at which a sharp corner is drawn beveled. More...
 
void setStrokeMiter (SkScalar miter)
 Sets the limit at which a sharp corner is drawn beveled. More...
 
Cap getStrokeCap () const
 Returns the geometry drawn at the beginning and end of strokes. More...
 
void setStrokeCap (Cap cap)
 Sets the geometry drawn at the beginning and end of strokes. More...
 
Join getStrokeJoin () const
 Returns the geometry drawn at the corners of strokes. More...
 
void setStrokeJoin (Join join)
 Sets the geometry drawn at the corners of strokes. More...
 
bool getFillPath (const SkPath &src, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1) const
 Returns the filled equivalent of the stroked path. More...
 
bool getFillPath (const SkPath &src, SkPath *dst) const
 Returns the filled equivalent of the stroked path. More...
 
SkShadergetShader () const
 Returns optional colors used when filling a path, such as a gradient. More...
 
sk_sp< SkShaderrefShader () const
 Returns optional colors used when filling a path, such as a gradient. More...
 
void setShader (sk_sp< SkShader > shader)
 Sets optional colors used when filling a path, such as a gradient. More...
 
SkColorFiltergetColorFilter () const
 Returns SkColorFilter if set, or nullptr. More...
 
sk_sp< SkColorFilterrefColorFilter () const
 Returns SkColorFilter if set, or nullptr. More...
 
void setColorFilter (sk_sp< SkColorFilter > colorFilter)
 Sets SkColorFilter to filter, decreasing SkRefCnt of the previous SkColorFilter. More...
 
SkBlendMode getBlendMode () const
 Returns SkBlendMode. More...
 
bool isSrcOver () const
 Returns true if SkBlendMode is SkBlendMode::kSrcOver, the default. More...
 
void setBlendMode (SkBlendMode mode)
 Sets SkBlendMode to mode. More...
 
SkPathEffectgetPathEffect () const
 Returns SkPathEffect if set, or nullptr. More...
 
sk_sp< SkPathEffectrefPathEffect () const
 Returns SkPathEffect if set, or nullptr. More...
 
void setPathEffect (sk_sp< SkPathEffect > pathEffect)
 Sets SkPathEffect to pathEffect, decreasing SkRefCnt of the previous SkPathEffect. More...
 
SkMaskFiltergetMaskFilter () const
 Returns SkMaskFilter if set, or nullptr. More...
 
sk_sp< SkMaskFilterrefMaskFilter () const
 Returns SkMaskFilter if set, or nullptr. More...
 
void setMaskFilter (sk_sp< SkMaskFilter > maskFilter)
 Sets SkMaskFilter to maskFilter, decreasing SkRefCnt of the previous SkMaskFilter. More...
 
SkImageFiltergetImageFilter () const
 Returns SkImageFilter if set, or nullptr. More...
 
sk_sp< SkImageFilterrefImageFilter () const
 Returns SkImageFilter if set, or nullptr. More...
 
void setImageFilter (sk_sp< SkImageFilter > imageFilter)
 Sets SkImageFilter to imageFilter, decreasing SkRefCnt of the previous SkImageFilter. More...
 
bool nothingToDraw () const
 Returns true if SkPaint prevents all drawing; otherwise, the SkPaint may or may not allow drawing. More...
 
bool canComputeFastBounds () const
 (to be made private) Returns true if SkPaint does not include elements requiring extensive computation to compute SkBaseDevice bounds of drawn geometry. More...
 
const SkRectcomputeFastBounds (const SkRect &orig, SkRect *storage) const
 (to be made private) Only call this if canComputeFastBounds() returned true. More...
 
const SkRectcomputeFastStrokeBounds (const SkRect &orig, SkRect *storage) const
 (to be made private) More...
 
const SkRectdoComputeFastBounds (const SkRect &orig, SkRect *storage, Style style) const
 (to be made private) Computes the bounds, overriding the SkPaint SkPaint::Style. More...
 

Static Public Attributes

static constexpr int kStyleCount = kStrokeAndFill_Style + 1
 May be used to verify that SkPaint::Style is a legal value. More...
 
static constexpr int kCapCount = kLast_Cap + 1
 May be used to verify that SkPaint::Cap is a legal value. More...
 
static constexpr int kJoinCount = kLast_Join + 1
 May be used to verify that SkPaint::Join is a legal value. More...
 

Friends

SK_API friend bool operator== (const SkPaint &a, const SkPaint &b)
 Compares a and b, and returns true if a and b are equivalent. More...
 
bool operator!= (const SkPaint &a, const SkPaint &b)
 Compares a and b, and returns true if a and b are not equivalent. More...
 

Detailed Description

SkPaint controls options applied when drawing. SkPaint collects all options outside of the SkCanvas clip and SkCanvas matrix.

Various options apply to strokes and fills, and images.

SkPaint collects effects and filters that describe single-pass and multiple-pass algorithms that alter the drawing geometry, color, and transparency. For instance, SkPaint does not directly implement dashing or blur, but contains the objects that do so.

Member Enumeration Documentation

◆ Cap

Enumerator
kButt_Cap 

no stroke extension

kRound_Cap 

adds circle

kSquare_Cap 

adds square

kLast_Cap 

largest Cap value

kDefault_Cap 

equivalent to kButt_Cap

◆ Join

enum SkPaint::Join : uint8_t
Enumerator
kMiter_Join 

extends to miter limit

kRound_Join 

adds circle

kBevel_Join 

connects outside edges

kLast_Join 

equivalent to the largest value for Join

kDefault_Join 

equivalent to kMiter_Join

◆ Style

enum SkPaint::Style : uint8_t
Enumerator
kFill_Style 

set to fill geometry

kStroke_Style 

set to stroke geometry

kStrokeAndFill_Style 

sets to stroke and fill geometry

Constructor & Destructor Documentation

◆ SkPaint() [1/4]

SkPaint::SkPaint ( )

Constructs SkPaint with default values.

Returns
default initialized SkPaint

example: https://fiddle.skia.org/c/@Paint_empty_constructor

◆ SkPaint() [2/4]

SkPaint::SkPaint ( const SkColor4f color,
SkColorSpace colorSpace = nullptr 
)
explicit

Constructs SkPaint with default values and the given 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 the colorSpace. If colorSpace is nullptr, then color is assumed to be in the sRGB color space.

Parameters
colorunpremultiplied RGBA
colorSpaceSkColorSpace describing the encoding of color
Returns
SkPaint with the given color

◆ SkPaint() [3/4]

SkPaint::SkPaint ( const SkPaint paint)

Makes a shallow copy of SkPaint.

SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, and SkImageFilter are shared between the original paint and the copy. Objects containing SkRefCnt increment their references by one.

The referenced objects SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, and SkImageFilter cannot be modified after they are created. This prevents objects with SkRefCnt from being modified once SkPaint refers to them.

Parameters
paintoriginal to copy
Returns
shallow copy of paint

example: https://fiddle.skia.org/c/@Paint_copy_const_SkPaint

◆ SkPaint() [4/4]

SkPaint::SkPaint ( SkPaint &&  paint)

Implements a move constructor to avoid increasing the reference counts of objects referenced by the paint.

After the call, paint is undefined, and can be safely destructed.

Parameters
paintoriginal to move
Returns
content of paint

example: https://fiddle.skia.org/c/@Paint_move_SkPaint

◆ ~SkPaint()

SkPaint::~SkPaint ( )

Decreases SkPaint SkRefCnt of owned objects: SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, and SkImageFilter.

If the objects containing SkRefCnt go to zero, they are deleted.

Member Function Documentation

◆ canComputeFastBounds()

bool SkPaint::canComputeFastBounds ( ) const

(to be made private) Returns true if SkPaint does not include elements requiring extensive computation to compute SkBaseDevice bounds of drawn geometry.

For instance, SkPaint with SkPathEffect always returns false.

Returns
true if SkPaint allows for fast computation of bounds

◆ computeFastBounds()

const SkRect& SkPaint::computeFastBounds ( const SkRect orig,
SkRect storage 
) const
inline

(to be made private) Only call this if canComputeFastBounds() returned true.

This takes a raw rectangle (the raw bounds of a shape), and adjusts it for stylistic effects in the paint (e.g. stroking). If needed, it uses the storage parameter. It returns the adjusted bounds that can then be used for SkCanvas::quickReject tests.

The returned SkRect will either be orig or storage, thus the caller should not rely on storage being set to the result, but should always use the returned value. It is legal for orig and storage to be the same SkRect. For example: if (!path.isInverseFillType() && paint.canComputeFastBounds()) { SkRect storage; if (canvas->quickReject(paint.computeFastBounds(path.getBounds(), &storage))) { return; // do not draw the path } } draw the path

    @param orig     geometry modified by SkPaint when drawn
    @param storage  computed bounds of geometry; may not be nullptr
    @return         fast computed bounds

◆ computeFastStrokeBounds()

const SkRect& SkPaint::computeFastStrokeBounds ( const SkRect orig,
SkRect storage 
) const
inline

(to be made private)

Parameters
origgeometry modified by SkPaint when drawn
storagecomputed bounds of geometry
Returns
fast computed bounds

◆ doComputeFastBounds()

const SkRect& SkPaint::doComputeFastBounds ( const SkRect orig,
SkRect storage,
Style  style 
) const

(to be made private) Computes the bounds, overriding the SkPaint SkPaint::Style.

This can be used to account for additional width required by stroking orig, without altering SkPaint::Style set to fill.

Parameters
origgeometry modified by SkPaint when drawn
storagecomputed bounds of geometry
styleoverrides SkPaint::Style
Returns
fast computed bounds

◆ getAlpha()

uint8_t SkPaint::getAlpha ( ) const
inline

◆ getAlphaf()

float SkPaint::getAlphaf ( ) const
inline

Retrieves alpha from the color used when stroking and filling.

Returns
alpha ranging from zero, fully transparent, to 255, fully opaque

◆ getBlendMode()

SkBlendMode SkPaint::getBlendMode ( ) const
inline

Returns SkBlendMode.

By default, returns SkBlendMode::kSrcOver.

Returns
mode used to combine source color with destination color

◆ getColor()

SkColor SkPaint::getColor ( ) const
inline

Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.

Use helpers SkColorGetA(), SkColorGetR(), SkColorGetG(), and SkColorGetB() to extract a color component.

Returns
unpremultiplied ARGB

◆ getColor4f()

SkColor4f SkPaint::getColor4f ( ) const
inline

Retrieves alpha and RGB, unpremultiplied, as four floating point values.

RGB are are extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).

Returns
unpremultiplied RGBA

◆ getColorFilter()

SkColorFilter* SkPaint::getColorFilter ( ) const
inline

Returns SkColorFilter if set, or nullptr.

Does not alter SkColorFilter SkRefCnt.

Returns
SkColorFilter if previously set, nullptr otherwise

◆ getFillPath() [1/2]

bool SkPaint::getFillPath ( const SkPath src,
SkPath dst 
) const
inline

Returns the filled equivalent of the stroked path.

Replaces dst with the src path modified by SkPathEffect and style stroke. SkPathEffect, if any, is not culled. stroke width is created with default precision.

Parameters
srcSkPath read to create a filled version
dstresulting SkPath dst may be the same as src, but may not be nullptr
Returns
true if the path represents style fill, or false if it represents hairline

◆ getFillPath() [2/2]

bool SkPaint::getFillPath ( const SkPath src,
SkPath dst,
const SkRect cullRect,
SkScalar  resScale = 1 
) const

Returns the filled equivalent of the stroked path.

Parameters
srcSkPath read to create a filled version
dstresulting SkPath; may be the same as src, but may not be nullptr
cullRectoptional limit passed to SkPathEffect
resScaleif > 1, increase precision, else if (0 < resScale < 1) reduce precision to favor speed and size
Returns
true if the path represents style fill, or false if it represents hairline

◆ getFilterQuality()

SkFilterQuality SkPaint::getFilterQuality ( ) const
inline

Returns SkFilterQuality, the image filtering level.

A lower setting draws faster; a higher setting looks better when the image is scaled.

◆ getHash()

uint32_t SkPaint::getHash ( ) const

Returns a hash generated from SkPaint values and pointers.

Identical hashes guarantee that the paints are equivalent, but differing hashes do not guarantee that the paints have differing contents.

If operator==(const SkPaint& a, const SkPaint& b) returns true for two paints, their hashes are also equal.

The hash returned is platform and implementation specific.

Returns
a shallow hash

example: https://fiddle.skia.org/c/@Paint_getHash

◆ getImageFilter()

SkImageFilter* SkPaint::getImageFilter ( ) const
inline

Returns SkImageFilter if set, or nullptr.

Does not alter SkImageFilter SkRefCnt.

Returns
SkImageFilter if previously set, nullptr otherwise

◆ getMaskFilter()

SkMaskFilter* SkPaint::getMaskFilter ( ) const
inline

Returns SkMaskFilter if set, or nullptr.

Does not alter SkMaskFilter SkRefCnt.

Returns
SkMaskFilter if previously set, nullptr otherwise

◆ getPathEffect()

SkPathEffect* SkPaint::getPathEffect ( ) const
inline

Returns SkPathEffect if set, or nullptr.

Does not alter SkPathEffect SkRefCnt.

Returns
SkPathEffect if previously set, nullptr otherwise

◆ getShader()

SkShader* SkPaint::getShader ( ) const
inline

Returns optional colors used when filling a path, such as a gradient.

Does not alter SkShader SkRefCnt.

Returns
SkShader if previously set, nullptr otherwise

◆ getStrokeCap()

Cap SkPaint::getStrokeCap ( ) const
inline

Returns the geometry drawn at the beginning and end of strokes.

◆ getStrokeJoin()

Join SkPaint::getStrokeJoin ( ) const
inline

Returns the geometry drawn at the corners of strokes.

◆ getStrokeMiter()

SkScalar SkPaint::getStrokeMiter ( ) const
inline

Returns the limit at which a sharp corner is drawn beveled.

Returns
zero and greater miter limit

◆ getStrokeWidth()

SkScalar SkPaint::getStrokeWidth ( ) const
inline

Returns the thickness of the pen used by SkPaint to outline the shape.

Returns
zero for hairline, greater than zero for pen thickness

◆ getStyle()

Style SkPaint::getStyle ( ) const
inline

Returns whether the geometry is filled, stroked, or filled and stroked.

◆ isAntiAlias()

bool SkPaint::isAntiAlias ( ) const
inline

Returns true if pixels on the active edges of SkPath may be drawn with partial transparency.

Returns
antialiasing state

◆ isDither()

bool SkPaint::isDither ( ) const
inline

Returns true if color error may be distributed to smooth color transition.

Returns
dithering state

◆ isSrcOver()

bool SkPaint::isSrcOver ( ) const
inline

Returns true if SkBlendMode is SkBlendMode::kSrcOver, the default.

Returns
true if SkBlendMode is SkBlendMode::kSrcOver

◆ nothingToDraw()

bool SkPaint::nothingToDraw ( ) const

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

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

Returns
true if SkPaint prevents all drawing

example: https://fiddle.skia.org/c/@Paint_nothingToDraw

◆ operator=() [1/2]

SkPaint& SkPaint::operator= ( const SkPaint paint)

Makes a shallow copy of SkPaint.

SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, and SkImageFilter are shared between the original paint and the copy. Objects containing SkRefCnt in the prior destination are decreased by one, and the referenced objects are deleted if the resulting count is zero. Objects containing SkRefCnt in the parameter paint are increased by one. paint is unmodified.

Parameters
paintoriginal to copy
Returns
content of paint

example: https://fiddle.skia.org/c/@Paint_copy_operator

◆ operator=() [2/2]

SkPaint& SkPaint::operator= ( SkPaint &&  paint)

Moves the paint to avoid increasing the reference counts of objects referenced by the paint parameter.

Objects containing SkRefCnt in the prior destination are decreased by one; those objects are deleted if the resulting count is zero.

After the call, paint is undefined, and can be safely destructed.

Parameters
paintoriginal to move
Returns
content of paint

example: https://fiddle.skia.org/c/@Paint_move_operator

◆ refColorFilter()

sk_sp<SkColorFilter> SkPaint::refColorFilter ( ) const

Returns SkColorFilter if set, or nullptr.

Increases SkColorFilter SkRefCnt by one.

Returns
SkColorFilter if set, or nullptr

example: https://fiddle.skia.org/c/@Paint_refColorFilter

◆ refImageFilter()

sk_sp<SkImageFilter> SkPaint::refImageFilter ( ) const

Returns SkImageFilter if set, or nullptr.

Increases SkImageFilter SkRefCnt by one.

Returns
SkImageFilter if previously set, nullptr otherwise

example: https://fiddle.skia.org/c/@Paint_refImageFilter

◆ refMaskFilter()

sk_sp<SkMaskFilter> SkPaint::refMaskFilter ( ) const

Returns SkMaskFilter if set, or nullptr.

Increases SkMaskFilter SkRefCnt by one.

Returns
SkMaskFilter if previously set, nullptr otherwise

example: https://fiddle.skia.org/c/@Paint_refMaskFilter

◆ refPathEffect()

sk_sp<SkPathEffect> SkPaint::refPathEffect ( ) const

Returns SkPathEffect if set, or nullptr.

Increases SkPathEffect SkRefCnt by one.

Returns
SkPathEffect if previously set, nullptr otherwise

example: https://fiddle.skia.org/c/@Paint_refPathEffect

◆ refShader()

sk_sp<SkShader> SkPaint::refShader ( ) const

Returns optional colors used when filling a path, such as a gradient.

Increases SkShader SkRefCnt by one.

Returns
SkShader if previously set, nullptr otherwise

example: https://fiddle.skia.org/c/@Paint_refShader

◆ reset()

void SkPaint::reset ( )

Sets all SkPaint contents to their initial values.

This is equivalent to replacing SkPaint with the result of SkPaint().

example: https://fiddle.skia.org/c/@Paint_reset

◆ setAlpha()

void SkPaint::setAlpha ( U8CPU  a)
inline

◆ setAlphaf()

void SkPaint::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 0.0 to 1.0. a set to zero makes color fully transparent; a set to 1.0 makes color fully opaque.

Parameters
aalpha component of color

◆ setAntiAlias()

void SkPaint::setAntiAlias ( bool  aa)
inline

Requests, but does not require, that edge pixels draw opaque or with partial transparency.

Parameters
aasetting for antialiasing

◆ setARGB()

void SkPaint::setARGB ( U8CPU  a,
U8CPU  r,
U8CPU  g,
U8CPU  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
aamount of alpha, from fully transparent (0) to fully opaque (255)
ramount of red, from no red (0) to full red (255)
gamount of green, from no green (0) to full green (255)
bamount of blue, from no blue (0) to full blue (255)

example: https://fiddle.skia.org/c/@Paint_setARGB

◆ setBlendMode()

void SkPaint::setBlendMode ( SkBlendMode  mode)
inline

Sets SkBlendMode to mode.

Does not check for valid input.

Parameters
modeSkBlendMode used to combine source color and destination

◆ setColor() [1/2]

void SkPaint::setColor ( const SkColor4f color,
SkColorSpace colorSpace = nullptr 
)

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
colorunpremultiplied RGBA
colorSpaceSkColorSpace describing the encoding of color

◆ setColor() [2/2]

void SkPaint::setColor ( SkColor  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
colorunpremultiplied ARGB

example: https://fiddle.skia.org/c/@Paint_setColor

◆ setColor4f()

void SkPaint::setColor4f ( const SkColor4f color,
SkColorSpace colorSpace = nullptr 
)
inline

◆ setColorFilter()

void SkPaint::setColorFilter ( sk_sp< SkColorFilter colorFilter)

Sets SkColorFilter to filter, decreasing SkRefCnt of the previous SkColorFilter.

Pass nullptr to clear SkColorFilter.

Increments filter SkRefCnt by one.

Parameters
colorFilterSkColorFilter to apply to subsequent draw

example: https://fiddle.skia.org/c/@Blend_Mode_Methods example: https://fiddle.skia.org/c/@Paint_setColorFilter

◆ setDither()

void SkPaint::setDither ( bool  dither)
inline

Requests, but does not require, to distribute color error.

Parameters
dithersetting for ditering

◆ setFilterQuality()

void SkPaint::setFilterQuality ( SkFilterQuality  quality)

Sets SkFilterQuality, the image filtering level.

A lower setting draws faster; a higher setting looks better when the image is scaled. Does not check to see if quality is valid.

example: https://fiddle.skia.org/c/@Color_Methods example: https://fiddle.skia.org/c/@Paint_setFilterQuality

◆ setImageFilter()

void SkPaint::setImageFilter ( sk_sp< SkImageFilter imageFilter)

Sets SkImageFilter to imageFilter, decreasing SkRefCnt of the previous SkImageFilter.

Pass nullptr to clear SkImageFilter, and remove SkImageFilter effect on drawing.

Increments imageFilter SkRefCnt by one.

Parameters
imageFilterhow SkImage is sampled when transformed

example: https://fiddle.skia.org/c/@Paint_setImageFilter

◆ setMaskFilter()

void SkPaint::setMaskFilter ( sk_sp< SkMaskFilter maskFilter)

Sets SkMaskFilter to maskFilter, decreasing SkRefCnt of the previous SkMaskFilter.

Pass nullptr to clear SkMaskFilter and leave SkMaskFilter effect on mask alpha unaltered.

Increments maskFilter SkRefCnt by one.

Parameters
maskFiltermodifies clipping mask generated from drawn geometry

example: https://fiddle.skia.org/c/@Paint_setMaskFilter example: https://fiddle.skia.org/c/@Typeface_Methods

◆ setPathEffect()

void SkPaint::setPathEffect ( sk_sp< SkPathEffect pathEffect)

Sets SkPathEffect to pathEffect, decreasing SkRefCnt of the previous SkPathEffect.

Pass nullptr to leave the path geometry unaltered.

Increments pathEffect SkRefCnt by one.

Parameters
pathEffectreplace SkPath with a modification when drawn

example: https://fiddle.skia.org/c/@Mask_Filter_Methods example: https://fiddle.skia.org/c/@Paint_setPathEffect

◆ setShader()

void SkPaint::setShader ( sk_sp< SkShader shader)

Sets optional colors used when filling a path, such as a gradient.

Sets SkShader to shader, decreasing SkRefCnt of the previous SkShader. Increments shader SkRefCnt by one.

Parameters
shaderhow geometry is filled with color; if nullptr, color is used instead

example: https://fiddle.skia.org/c/@Color_Filter_Methods example: https://fiddle.skia.org/c/@Paint_setShader

◆ setStroke()

void SkPaint::setStroke ( bool  )

Set paint's style to kStroke if true, or kFill if false.

◆ setStrokeCap()

void SkPaint::setStrokeCap ( Cap  cap)

Sets the geometry drawn at the beginning and end of strokes.

example: https://fiddle.skia.org/c/@Paint_setStrokeCap_a example: https://fiddle.skia.org/c/@Paint_setStrokeCap_b

◆ setStrokeJoin()

void SkPaint::setStrokeJoin ( Join  join)

Sets the geometry drawn at the corners of strokes.

example: https://fiddle.skia.org/c/@Paint_setStrokeJoin

◆ setStrokeMiter()

void SkPaint::setStrokeMiter ( SkScalar  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
miterzero and greater miter limit

example: https://fiddle.skia.org/c/@Paint_setStrokeMiter

◆ setStrokeWidth()

void SkPaint::setStrokeWidth ( SkScalar  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
widthzero thickness for hairline; greater than zero for pen thickness

example: https://fiddle.skia.org/c/@Miter_Limit example: https://fiddle.skia.org/c/@Paint_setStrokeWidth

◆ setStyle()

void SkPaint::setStyle ( Style  style)

Sets whether the geometry is filled, stroked, or filled and stroked.

Has no effect if style is not a legal SkPaint::Style value.

example: https://fiddle.skia.org/c/@Paint_setStyle example: https://fiddle.skia.org/c/@Stroke_Width

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const SkPaint a,
const SkPaint b 
)
friend

Compares a and b, and returns true if a and b are not equivalent.

May return true if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, or SkImageFilter have identical contents but different pointers.

Parameters
aSkPaint to compare
bSkPaint to compare
Returns
true if SkPaint pair are not equivalent

◆ operator==

SK_API friend bool operator== ( const SkPaint a,
const SkPaint b 
)
friend

Compares a and b, and returns true if a and b are equivalent.

May return false if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter, or SkImageFilter have identical contents but different pointers.

Parameters
aSkPaint to compare
bSkPaint to compare
Returns
true if SkPaint pair are equivalent

Member Data Documentation

◆ fAntiAlias

unsigned SkPaint::fAntiAlias

◆ fBitfields

struct { ... } SkPaint::fBitfields

◆ fBitfieldsUInt

uint32_t SkPaint::fBitfieldsUInt

◆ fBlendMode

unsigned SkPaint::fBlendMode

◆ fCapType

unsigned SkPaint::fCapType

◆ fDither

unsigned SkPaint::fDither

◆ fFilterQuality

unsigned SkPaint::fFilterQuality

◆ fJoinType

unsigned SkPaint::fJoinType

◆ fPadding

unsigned SkPaint::fPadding

◆ fStyle

unsigned SkPaint::fStyle

◆ kCapCount

constexpr int SkPaint::kCapCount = kLast_Cap + 1
staticconstexpr

May be used to verify that SkPaint::Cap is a legal value.

◆ kJoinCount

constexpr int SkPaint::kJoinCount = kLast_Join + 1
staticconstexpr

May be used to verify that SkPaint::Join is a legal value.

◆ kStyleCount

constexpr int SkPaint::kStyleCount = kStrokeAndFill_Style + 1
staticconstexpr

May be used to verify that SkPaint::Style is a legal value.


The documentation for this class was generated from the following file: