rect |
maximum allowed clip in device coordinates |
#
---
## clipRRect
void clipRRect(const SkRRect& rrect, SkClipOp op, bool doAntiAlias)
Replace Clip with the intersection or difference of Clip and rrect,
with an Aliased or Anti-aliased clip edge.
rrect is transformed by Matrix
before it is combined with Clip.
### Parameters
### Example
### See Also
clipRect[2][3] clipPath[2][3] clipRegion
---
void clipRRect(const SkRRect& rrect, SkClipOp op)
Replace Clip with the intersection or difference of Clip and rrect.
Resulting Clip is Aliased; pixels are fully contained by the clip.
rrect is transformed by Matrix before it is combined with Clip.
### Parameters
### Example
### See Also
clipRect[2][3] clipPath[2][3] clipRegion
---
void clipRRect(const SkRRect& rrect, bool doAntiAlias = false)
Replace Clip with the intersection of Clip and rrect,
with an Aliased or Anti-aliased clip edge.
rrect is transformed by Matrix before it is combined with Clip.
### Parameters
### Example
### See Also
clipRect[2][3] clipPath[2][3] clipRegion
---
## clipPath
void clipPath(const SkPath& path, SkClipOp op, bool doAntiAlias)
Replace Clip with the intersection or difference of Clip and path,
with an Aliased or Anti-aliased clip edge. Path Fill Type determines if path
describes the area inside or outside its contours; and if Path Contour overlaps
itself or another Path Contour, whether the overlaps form part of the area.
path is transformed by Matrix before it is combined with Clip.
### Parameters
### Example
### See Also
clipRect[2][3] clipRRect[2][3] clipRegion
---
void clipPath(const SkPath& path, SkClipOp op)
Replace Clip with the intersection or difference of Clip and path.
Resulting Clip is Aliased; pixels are fully contained by the clip.
Path Fill Type determines if path
describes the area inside or outside its contours; and if Path Contour overlaps
itself or another Path Contour, whether the overlaps form part of the area.
path is transformed by Matrix
before it is combined with Clip.
### Parameters
### Example
### See Also
clipRect[2][3] clipRRect[2][3] clipRegion
---
void clipPath(const SkPath& path, bool doAntiAlias = false)
Replace Clip with the intersection of Clip and path.
Resulting Clip is Aliased; pixels are fully contained by the clip.
Path Fill Type determines if path
describes the area inside or outside its contours; and if Path Contour overlaps
itself or another Path Contour, whether the overlaps form part of the area.
path is transformed by Matrix before it is combined with Clip.
### Parameters
### Example
### See Also
clipRect[2][3] clipRRect[2][3] clipRegion
---
## setAllowSimplifyClip
void setAllowSimplifyClip(bool allow)
Only used for testing.
Set to simplify clip stack using PathOps.
---
## clipRegion
void clipRegion(const SkRegion& deviceRgn, SkClipOp op = SkClipOp::kIntersect)
Replace Clip with the intersection or difference of Clip and Region deviceRgn.
Resulting Clip is Aliased; pixels are fully contained by the clip.
deviceRgn is unaffected by Matrix.
### Parameters
### Example
region is unaffected by canvas rotation; iRect is affected by canvas rotation.
Both clips are
Aliased; this is not noticeable on
Region clip because it
aligns to pixel boundaries.
### See Also
clipRect[2][3] clipRRect[2][3] clipPath[2][3]
---
## quickReject
bool quickReject(const SkRect& rect) const
Return true if Rect rect, transformed by Matrix, can be quickly determined to be
outside of Clip. May return false even though rect is outside of Clip.
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
### Parameters
### Return Value
true if rect, transformed by Matrix, does not intersect Clip
### Example
#### Example Output
~~~~
quickReject true
quickReject false
~~~~
### See Also
getLocalClipBounds[2] getTotalMatrix SkBitmap::drawsNothing
---
bool quickReject(const SkPath& path) const
Return true if path, transformed by Matrix, can be quickly determined to be
outside of Clip. May return false even though path is outside of Clip.
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
### Parameters
### Return Value
true if path, transformed by Matrix, does not intersect Clip
### Example
#### Example Output
~~~~
quickReject true
quickReject false
~~~~
### See Also
getLocalClipBounds[2] getTotalMatrix SkBitmap::drawsNothing
---
## getLocalClipBounds
SkRect getLocalClipBounds() const
Return bounds of Clip, transformed by inverse of Matrix. If Clip is empty,
return SkRect::MakeEmpty, where all Rect sides equal zero.
Rect returned is outset by one to account for partial pixel coverage if Clip
is Anti-aliased.
### Return Value
bounds of Clip in local coordinates
### Example
Initial bounds is device bounds outset by 1 on all sides.
Clipped bounds is
clipPath bounds outset by 1 on all sides.
Scaling the canvas by two in x and y scales the local bounds by 1/2 in x and y.
#### Example Output
~~~~
left:-1 top:-1 right:257 bottom:257
left:29 top:129 right:121 bottom:231
left:14.5 top:64.5 right:60.5 bottom:115.5
~~~~
### See Also
getDeviceClipBounds[2] getBaseLayerSize quickReject[2]
---
bool getLocalClipBounds(SkRect* bounds) const
Return bounds of Clip, transformed by inverse of Matrix. If Clip is empty,
return false, and set bounds to SkRect::MakeEmpty, where all Rect sides equal zero.
bounds is outset by one to account for partial pixel coverage if Clip
is Anti-aliased.
### Parameters
### Return Value
true if Clip bounds is not empty
### Example
#### Example Output
~~~~
local bounds empty = false
local bounds empty = true
~~~~
### See Also
getDeviceClipBounds[2] getBaseLayerSize quickReject[2]
---
## getDeviceClipBounds
SkIRect getDeviceClipBounds() const
Return IRect bounds of Clip, unaffected by Matrix. If Clip is empty,
return SkRect::MakeEmpty, where all Rect sides equal zero.
Unlike getLocalClipBounds, returned IRect is not outset.
### Return Value
bounds of Clip in Device coordinates
### Example
Initial bounds is device bounds, not outset.
Clipped bounds is
clipPath bounds, not outset.
Scaling the canvas by 1/2 in x and y scales the device bounds by 1/2 in x and y.
#### Example Output
~~~~
left:0 top:0 right:256 bottom:256
left:30 top:130 right:120 bottom:230
left:15 top:65 right:60 bottom:115
~~~~
### See Also
getLocalClipBounds[2] getBaseLayerSize quickReject[2]
---
bool getDeviceClipBounds(SkIRect* bounds) const
Return IRect bounds of Clip, unaffected by Matrix. If Clip is empty,
return false, and set bounds to SkRect::MakeEmpty, where all Rect sides equal zero.
Unlike getLocalClipBounds, bounds is not outset.
### Parameters
### Return Value
true if Clip bounds is not empty
### Example
#### Example Output
~~~~
device bounds empty = false
device bounds empty = true
~~~~
### See Also
getLocalClipBounds[2] getBaseLayerSize quickReject[2]
---
## Draw
| name | description |
| --- | --- |
| clear | fills Clip with Color |
| drawAnnotation | associates a Rect with a key-value pair |
| | drawAnnotation(const SkRect& rect, const char key[], SkData* value) |
| | drawAnnotation(const SkRect& rect, const char key[], const sk sp<SkData>& value) |
| drawArc | draws Arc using Clip, Matrix, and Paint |
| drawAtlas | draws sprites using Clip, Matrix, and Paint |
| | drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect, const SkPaint* paint) |
| | drawAtlas(const sk sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect, const SkPaint* paint) |
| | drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count, const SkRect* cullRect, const SkPaint* paint) |
| | drawAtlas(const sk sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[], int count, const SkRect* cullRect, const SkPaint* paint) |
| drawCircle | draws Circle using Clip, Matrix, and Paint |
| | drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint) |
| | drawCircle(SkPoint center, SkScalar radius, const SkPaint& paint) |
| drawColor | fills Clip with Color and Blend Mode |
| drawDRRect | draws double Round Rect stroked or filled |
| drawDrawable | draws Drawable, encapsulated drawing commands |
| | drawDrawable(SkDrawable* drawable, const SkMatrix* matrix = nullptr) |
| | drawDrawable(SkDrawable* drawable, SkScalar x, SkScalar y) |
| drawIRect | draws IRect using Clip, Matrix, and Paint |
| drawLine | draws line segment between two points |
| | drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint& paint) |
| | drawLine(SkPoint p0, SkPoint p1, const SkPaint& paint) |
| drawOval | draws Oval using Clip, Matrix, and Paint |
| drawPaint | fills Clip with Paint |
| drawPatch | draws Coons_Patch |
| | drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint) |
| | drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], const SkPaint& paint) |
| drawPath | draws Path using Clip, Matrix, and Paint |
| drawPicture | draws Picture using Clip and Matrix |
| | drawPicture(const SkPicture* picture) |
| | drawPicture(const sk sp<SkPicture>& picture) |
| | drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint) |
| | drawPicture(const sk sp<SkPicture>& picture, const SkMatrix* matrix, const SkPaint* paint) |
| drawPoint | draws point at (x, y) position |
| | drawPoint(SkScalar x, SkScalar y, const SkPaint& paint) |
| | drawPoint(SkPoint p, const SkPaint& paint) |
| drawPoints | draws array as points, lines, polygon |
| drawRRect | draws Round Rect using Clip, Matrix, and Paint |
| drawRect | draws Rect using Clip, Matrix, and Paint |
| drawRegion | draws Region using Clip, Matrix, and Paint |
| drawRoundRect | draws Round Rect using Clip, Matrix, and Paint |
| drawVertices | draws Vertices, a triangle mesh |
| | drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) |
| | drawVertices(const sk sp<SkVertices>& vertices, SkBlendMode mode, const SkPaint& paint) |
## drawColor
void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver)
Fill Clip with Color color.
mode determines how Color ARGB is combined with destination.
### Parameters
### Example
### See Also
clear SkBitmap::erase drawPaint
---
## clear
void clear(SkColor color)
Fill Clip with Color color using SkBlendMode::kSrc.
This has the effect of replacing all pixels contained by Clip with color.
### Parameters
### Example
### See Also
drawColor SkBitmap::erase drawPaint
---
## discard
void discard()
Make Canvas contents undefined. Subsequent calls that read Canvas pixels,
such as drawing with SkBlendMode, return undefined results. discard does
not change Clip or Matrix.
discard may do nothing, depending on the implementation of Surface or Device
that created Canvas.
discard allows optimized performance on subsequent draws by removing
cached data associated with Surface or Device.
It is not necessary to call discard once done with Canvas;
any cached data is deleted when owning Surface or Device is deleted.
### See Also
flush SkSurface::prepareForExternalIO GrContext::abandonContext
---
## drawPaint
void drawPaint(const SkPaint& paint)
Fill Clip with Paint paint. Paint components Mask Filter, Shader,
Color Filter, Image Filter, and Blend Mode affect drawing;
Path Effect in paint is ignored.
### Parameters
### Example
### See Also
clear drawColor SkBitmap::erase
---
## Enum SkCanvas::PointMode
enum PointMode {
kPoints PointMode,
kLines PointMode,
kPolygon PointMode,
};
Selects if an array of points are drawn as discrete points, as lines, or as
an open polygon.
### Constants
### Example
The upper left corner shows three squares when drawn as points.
The upper right corner shows one line; when drawn as lines, two points are required per line.
The lower right corner shows two lines; when draw as polygon, no miter is drawn at the corner.
The lower left corner shows two lines with a miter when path contains polygon.
### See Also
drawLine[2] drawPoint[2] drawPath
## drawPoints
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint)
Draw pts using Clip, Matrix and Paint paint.
count is the number of points; if count is less than one, has no effect.
mode may be one of: kPoints PointMode, kLines PointMode, or kPolygon PointMode.
If mode is kPoints PointMode, the shape of point drawn depends on paint
Paint Stroke Cap. If paint is set to SkPaint::kRound Cap, each point draws a
circle of diameter Paint Stroke Width. If paint is set to SkPaint::kSquare Cap
or SkPaint::kButt Cap, each point draws a square of width and height
Paint Stroke Width.
If mode is kLines PointMode, 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.
If mode is kPolygon PointMode, 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 Paint Stroke Cap and Paint Stroke Width.
Paint Style is ignored, as if were set to SkPaint::kStroke Style.
Always draws each element one at a time; is not affected by
Paint Stroke Join, and unlike drawPath, does not create a mask from all points
and lines before drawing.
### Parameters
mode |
whether pts draws points or lines |
count |
number of points in the array |
pts |
array of points to draw |
paint |
stroke, blend, color, and so on, used to draw |
### Example
The first column draws points. |
The second column draws points as lines. |
The third column draws points as a polygon. |
The fourth column draws points as a polygonal path. |
The first row uses a round cap and round join. |
The second row uses a square cap and a miter join. |
The third row uses a butt cap and a bevel join. |
The transparent color makes multiple line draws visible;
the path is drawn all at once.
### See Also
drawLine[2] drawPoint[2] drawPath
---
## drawPoint
void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint)
Draw point at (x, y) using Clip, Matrix and Paint paint.
The shape of point drawn depends on paint Paint Stroke Cap.
If paint is set to SkPaint::kRound Cap, draw a circle of diameter
Paint Stroke Width. If paint is set to SkPaint::kSquare Cap or SkPaint::kButt Cap,
draw a square of width and height Paint Stroke Width.
Paint Style is ignored, as if were set to SkPaint::kStroke Style.
### Parameters
x |
left edge of circle or square |
y |
top edge of circle or square |
paint |
stroke, blend, color, and so on, used to draw |
### Example
### See Also
drawPoints drawCircle[2] drawRect drawLine[2] drawPath
---
void drawPoint(SkPoint p, const SkPaint& paint)
Draw point p using Clip, Matrix and Paint paint.
The shape of point drawn depends on paint Paint Stroke Cap.
If paint is set to SkPaint::kRound Cap, draw a circle of diameter
Paint Stroke Width. If paint is set to SkPaint::kSquare Cap or SkPaint::kButt Cap,
draw a square of width and height Paint Stroke Width.
Paint Style is ignored, as if were set to SkPaint::kStroke Style.
### Parameters
p |
top-left edge of circle or square |
paint |
stroke, blend, color, and so on, used to draw |
### Example
### See Also
drawPoints drawCircle[2] drawRect drawLine[2] drawPath
---
## drawLine
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint& paint)
Draws line segment from (x0, y0) to (x1, y1) using Clip, Matrix, and Paint paint.
In paint: Paint Stroke Width describes the line thickness;
Paint Stroke Cap draws the end rounded or square;
Paint Style is ignored, as if were set to SkPaint::kStroke Style.
### Parameters
x0 |
start of line segment on x-axis |
y0 |
start of line segment on y-axis |
x1 |
end of line segment on x-axis |
y1 |
end of line segment on y-axis |
paint |
stroke, blend, color, and so on, used to draw |
### Example
### See Also
drawPoint[2] drawCircle[2] drawRect drawPath
---
void drawLine(SkPoint p0, SkPoint p1, const SkPaint& paint)
Draws line segment from p0 to p1 using Clip, Matrix, and Paint paint.
In paint: Paint Stroke Width describes the line thickness;
Paint Stroke Cap draws the end rounded or square;
Paint Style is ignored, as if were set to SkPaint::kStroke Style.
### Parameters
p0 |
start of line segment |
p1 |
end of line segment |
paint |
stroke, blend, color, and so on, used to draw |
### Example
### See Also
drawPoint[2] drawCircle[2] drawRect drawPath
---
## drawRect
void drawRect(const SkRect& rect, const SkPaint& paint)
Draw Rect rect using Clip, Matrix, and Paint paint.
In paint: Paint Style determines if rectangle is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness, and
Paint Stroke Join draws the corners rounded or square.
### Parameters
rect |
rectangle to draw |
paint |
stroke or fill, blend, color, and so on, used to draw |
### Example
### See Also
drawIRect drawRRect drawRoundRect drawRegion drawPath drawLine[2]
---
## drawIRect
void drawIRect(const SkIRect& rect, const SkPaint& paint)
Draw IRect rect using Clip, Matrix, and Paint paint.
In paint: Paint Style determines if rectangle is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness, and
Paint Stroke Join draws the corners rounded or square.
### Parameters
rect |
rectangle to draw |
paint |
stroke or fill, blend, color, and so on, used to draw |
### Example
### See Also
drawRect drawRRect drawRoundRect drawRegion drawPath drawLine[2]
---
## drawRegion
void drawRegion(const SkRegion& region, const SkPaint& paint)
Draw Region region using Clip, Matrix, and Paint paint.
In paint: Paint Style determines if rectangle is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness, and
Paint Stroke Join draws the corners rounded or square.
### Parameters
### Example
### See Also
drawRect drawIRect drawPath
---
## drawOval
void drawOval(const SkRect& oval, const SkPaint& paint)
Draw Oval oval using Clip, Matrix, and Paint.
In paint: Paint Style determines if Oval is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness.
### Parameters
### Example
### See Also
drawCircle[2] drawPoint[2] drawPath drawRRect drawRoundRect
---
## drawRRect
void drawRRect(const SkRRect& rrect, const SkPaint& paint)
Draw Round Rect rrect using Clip, Matrix, and Paint paint.
In paint: Paint Style determines if rrect is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness.
rrect may represent a rectangle, circle, oval, uniformly rounded rectangle, or
may have any combination of positive non-square radii for the four corners.
### Parameters
### Example
### See Also
drawRect drawRoundRect drawDRRect drawCircle[2] drawOval drawPath
---
## drawDRRect
void drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint)
Draw Round Rect outer and inner
using Clip, Matrix, and Paint paint.
outer must contain inner or the drawing is undefined.
In paint: Paint Style determines if Round Rect is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness.
If stroked and Round Rect corner has zero length radii, Paint Stroke Join can
draw corners rounded or square.
GPU-backed platforms optimize drawing when both outer and inner are
concave and outer contains inner. These platforms may not be able to draw
Path built with identical data as fast.
### Parameters
### Example
### Example
Outer
Rect has no corner radii, but stroke join is rounded.
Inner
Round Rect has corner radii; outset stroke increases radii of corners.
Stroke join does not affect
inner Round Rect since it has no sharp corners.
### See Also
drawRect drawRoundRect drawRRect drawCircle[2] drawOval drawPath
---
## drawCircle
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint)
Draw Circle at (cx, cy) with radius using Clip, Matrix, and Paint paint.
If radius is zero or less, nothing is drawn.
In paint: Paint Style determines if Circle is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness.
### Parameters
### Example
### See Also
drawOval drawRRect drawRoundRect drawPath drawArc drawPoint[2] drawLine[2]
---
void drawCircle(SkPoint center, SkScalar radius, const SkPaint& paint)
Draw Circle at center with radius using Clip, Matrix, and Paint paint.
If radius is zero or less, nothing is drawn.
In paint: Paint Style determines if Circle is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness.
### Parameters
### Example
### See Also
drawOval drawRRect drawRoundRect drawPath drawArc drawPoint[2] drawLine[2]
---
## drawArc
void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
const SkPaint& paint)
Draw Arc using Clip, Matrix, and Paint paint.
Arc is part of Oval bounded by oval, sweeping from startAngle to startAngle plus
sweepAngle. startAngle and sweepAngle are in degrees.
startAngle of zero places start point at the right middle edge of oval.
A positive sweepAngle places Arc end point clockwise from start point;
a negative sweepAngle places Arc end point counterclockwise from start point.
sweepAngle may exceed 360 degrees, a full circle.
If useCenter is true, draw a wedge that includes lines from oval
center to Arc end points. If useCenter is false, draw Arc between end points.
If Rect oval is empty or sweepAngle is zero, nothing is drawn.
### Parameters
### Example
### Example
### See Also
SkPath::arcTo[2][3][4][5] drawCircle[2] drawOval drawPath
---
## drawRoundRect
void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, const SkPaint& paint)
Draw Round Rect bounded by Rect rect, with corner radii (rx, ry) using Clip,
Matrix, and Paint paint.
In paint: Paint Style determines if Round Rect is stroked or filled;
if stroked, Paint Stroke Width describes the line thickness.
If rx or ry are less than zero, they are treated as if they are zero.
If rx plus ry exceeds rect width or rect height, radii are scaled down to fit.
If rx and ry are zero, Round Rect is drawn as Rect and if stroked is affected by
Paint Stroke Join.
### Parameters
rect |
Rect bounds of Round Rect to draw |
rx |
axis length in x of oval describing rounded corners |
ry |
axis length in y of oval describing rounded corners |
paint |
stroke, blend, color, and so on, used to draw |
### Example
Top row has a zero radius a generates a rectangle.
Second row radii sum to less than sides.
Third row radii sum equals sides.
Fourth row radii sum exceeds sides; radii are scaled to fit.
### See Also
DrawRRect drawRect drawDRRect drawPath drawCircle[2] drawOval drawPoint[2]
---
## drawPath
void drawPath(const SkPath& path, const SkPaint& paint)
Draw Path path using Clip, Matrix, and Paint paint.
Path contains an array of Path Contour, each of which may be open or closed.
In paint: Paint Style determines if Round Rect is stroked or filled:
if filled, Path Fill Type determines whether Path Contour describes inside or
outside of fill; if stroked, Paint Stroke Width describes the line thickness,
Paint Stroke Cap describes line ends, and Paint Stroke Join describes how
corners are drawn.
### Parameters
path |
Path to draw |
paint |
stroke, blend, color, and so on, used to draw |
### Example
Top rows draw stroked
path with combinations of joins and caps. The open contour
is affected by caps; the closed contour is affected by joins.
Bottom row draws fill the same for open and closed contour.
First bottom column shows winding fills overlap.
Second bottom column shows even odd fills exclude overlap.
Third bottom column shows inverse winding fills area outside both contours.
### See Also
SkPath drawLine[2] drawArc drawRect drawPoints
---
## Draw Image
drawImage, drawImageRect, and drawImageNine can be called with a bare pointer or
a smart pointer as a convenience. The pairs of calls are otherwise identical.
## drawImage
void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint = nullptr)
Draw Image image, with its top-left corner at (left, top),
using Clip, Matrix, and optional Paint paint.
If paint is supplied, apply Color Filter, Color Alpha, Image Filter, Blend Mode,
and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds. If generated
mask extends beyond image bounds, replicate image edge colors, just as Shader
made from SkImage::makeShader with SkShader::kClamp TileMode set replicates the
image edge color when it samples outside of its bounds.
### Parameters
### Example
### See Also
drawBitmap drawImageLattice drawImageNine[2] drawImageRect[2][3][4][5][6] SkPaint::setImageFilter
---
void drawImage(const sk_sp<SkImage>& image, SkScalar left, SkScalar top,
const SkPaint* paint = nullptr)
Draw Image image, with its top-left corner at (left, top),
using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds. If generated
mask extends beyond image bounds, replicate image edge colors, just as Shader
made from SkImage::makeShader with SkShader::kClamp TileMode set replicates the
image edge color when it samples outside of its bounds.
### Parameters
### Example
### See Also
drawBitmap drawImageLattice drawImageNine[2] drawImageRect[2][3][4][5][6] SkPaint::setImageFilter
---
## Enum SkCanvas::SrcRectConstraint
enum SrcRectConstraint {
kStrict SrcRectConstraint,
kFast SrcRectConstraint,
};
SrcRectConstraint controls the behavior at the edge of source Rect,
provided to drawImageRect, trading off speed for precision.
Image Filter in Paint may sample multiple pixels in the image. Source Rect
restricts the bounds of pixels that may be read. Image Filter may slow down if
it cannot read outside the bounds, when sampling near the edge of source Rect.
SrcRectConstraint specifies whether an Image Filter is allowed to read pixels
outside source Rect.
### Constants
### Example
redBorder contains a black and white checkerboard bordered by red.
redBorder is drawn scaled by 16 on the left.
The middle and right bitmaps are filtered checkerboards.
Drawing the checkerboard with
kStrict SrcRectConstraint shows only a blur of black and white.
Drawing the checkerboard with
kFast SrcRectConstraint allows red to bleed in the corners.
### See Also
drawImageRect[2][3][4][5][6] drawImage[2] SkPaint::setImageFilter
## drawImageRect
void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw Rect src of Image image, scaled and translated to fill Rect dst.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp TileMode set
replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within src; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
### See Also
SrcRectConstraint drawImage[2] drawImageLattice drawImageNine[2]
---
void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw IRect isrc of Image image, scaled and translated to fill Rect dst.
Note that isrc is on integer pixel boundaries; dst may include fractional
boundaries. Additionally transform draw using Clip, Matrix, and optional Paint
paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp TileMode set
replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within isrc; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
### See Also
SrcRectConstraint drawImage[2] drawImageLattice drawImageNine[2]
---
void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw Image image, scaled and translated to fill Rect dst, using Clip, Matrix,
and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp TileMode set
replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within image; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
### See Also
SrcRectConstraint drawImage[2] drawImageLattice drawImageNine[2]
---
void drawImageRect(const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw Rect src of Image image, scaled and translated to fill Rect dst.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp TileMode set
replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within src; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
Canvas scales and translates; transformation from
src to
dst also scales.
The two matrices are concatenated to create the final transformation.
### See Also
SrcRectConstraint drawImage[2] drawImageLattice drawImageNine[2]
---
void drawImageRect(const sk_sp<SkImage>& image, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw IRect isrc of Image image, scaled and translated to fill Rect dst.
isrc is on integer pixel boundaries; dst may include fractional boundaries.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp TileMode set
replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within image; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
### See Also
SrcRectConstraint drawImage[2] drawImageLattice drawImageNine[2]
---
void drawImageRect(const sk_sp<SkImage>& image, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw Image image, scaled and translated to fill Rect dst,
using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp TileMode set
replicates the image edge color when it samples outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within image; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
### See Also
SrcRectConstraint drawImage[2] drawImageLattice drawImageNine[2]
---
## drawImageNine
void drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
const SkPaint* paint = nullptr)
Draw Image image stretched proportionally to fit into Rect dst.
IRect center divides the image into nine sections: four sides, four corners, and
the center. Corners are unmodified or scaled down proportionately if their sides
are larger than dst; center and four sides are scaled to fit remaining space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp TileMode set
replicates the image edge color when it samples outside of its bounds.
### Parameters
### Example
The leftmost
image is smaller than
center; only corners are drawn, all scaled to fit.
The second
image equals the size of
center; only corners are drawn without scaling.
The remaining images are larger than
center. All corners draw without scaling.
The sides and
center are scaled if needed to take up the remaining space.
### See Also
drawImage[2] drawBitmapNine drawImageLattice drawImageRect[2][3][4][5][6]
---
void drawImageNine(const sk_sp<SkImage>& image, const SkIRect& center, const SkRect& dst,
const SkPaint* paint = nullptr)
Draw Image image stretched proportionally to fit into Rect dst.
IRect center divides the image into nine sections: four sides, four corners, and
the center. Corners are not scaled, or scaled down proportionately if their sides
are larger than dst; center and four sides are scaled to fit remaining space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from image bounds.
If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp TileMode set
replicates the image edge color when it samples outside of its bounds.
### Parameters
### Example
The two leftmost images has four corners and sides to the left and right of
center.
The leftmost
image scales the width of corners proportionately to fit.
The third and fourth
image corners are not scaled; the sides and
center are scaled to
fill the remaining space.
The rightmost
image has four corners scaled vertically to fit, and uses sides above
and below
center to fill the remaining space.
### See Also
drawImage[2] drawBitmapNine drawImageLattice drawImageRect[2][3][4][5][6]
---
## drawBitmap
void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint* paint = nullptr)
Draw Bitmap bitmap, with its top-left corner at (left, top),
using Clip, Matrix, and optional Paint paint.
If Paint paint is not nullptr, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp TileMode set replicates the bitmap edge color when it samples
outside of its bounds.
### Parameters
### Example
### See Also
drawImage[2] drawBitmapLattice drawBitmapNine drawBitmapRect[2][3] SkBitmap::readPixels[2][3][4] SkBitmap::writePixels[2][3]
---
## drawBitmapRect
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw Rect src of Bitmap bitmap, scaled and translated to fill Rect dst.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp TileMode set replicates the bitmap edge color when it samples
outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within src; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
### See Also
drawImageRect[2][3][4][5][6] drawBitmap drawBitmapLattice drawBitmapNine
---
void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw IRect isrc of Bitmap bitmap, scaled and translated to fill Rect dst.
isrc is on integer pixel boundaries; dst may include fractional boundaries.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp TileMode set replicates the bitmap edge color when it samples
outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within isrc; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
### See Also
drawImageRect[2][3][4][5][6] drawBitmap drawBitmapLattice drawBitmapNine
---
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint,
SrcRectConstraint constraint = kStrict_SrcRectConstraint)
Draw Bitmap bitmap, scaled and translated to fill Rect dst.
bitmap bounds is on integer pixel boundaries; dst may include fractional boundaries.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp TileMode set replicates the bitmap edge color when it samples
outside of its bounds.
constraint set to kStrict SrcRectConstraint limits Paint Filter Quality to
sample within bitmap; set to kFast SrcRectConstraint allows sampling outside to
improve performance.
### Parameters
### Example
### See Also
drawImageRect[2][3][4][5][6] drawBitmap drawBitmapLattice drawBitmapNine
---
## drawBitmapNine
void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
const SkPaint* paint = nullptr)
Draw Bitmap bitmap stretched proportionally to fit into Rect dst.
IRect center divides the bitmap into nine sections: four sides, four corners,
and the center. Corners are not scaled, or scaled down proportionately if their
sides are larger than dst; center and four sides are scaled to fit remaining
space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp TileMode set replicates the bitmap edge color when it samples
outside of its bounds.
### Parameters
### Example
The two leftmost
bitmap draws has four corners and sides to the left and right of
center.
The leftmost
bitmap draw scales the width of corners proportionately to fit.
The third and fourth draw corners are not scaled; the sides and
center are scaled to
fill the remaining space.
The rightmost
bitmap draw has four corners scaled vertically to fit, and uses sides above
and below
center to fill the remaining space.
### See Also
drawImageNine[2] drawBitmap drawBitmapLattice drawBitmapRect[2][3]
---
# Struct SkCanvas::Lattice
struct Lattice {
enum RectType ...
const int* fXDivs;
const int* fYDivs;
const RectType* fRectTypes;
int fXCount;
int fYCount;
const SkIRect* fBounds;
const SkColor* fColors;
};
Lattice divides Bitmap or Image into a rectangular grid.
Grid entries on even columns and even rows are fixed; these entries are
always drawn at their original size if the destination is large enough.
If the destination side is too small to hold the fixed entries, all fixed
entries are proportionately scaled down to fit.
The grid entries not on even columns and rows are scaled to fit the
remaining space, if any.
## Enum SkCanvas::Lattice::RectType
enum RectType : uint8_t {
kDefault = 0,
kTransparent,
kFixedColor,
};
Optional setting per rectangular grid entry to make it transparent,
or to fill the grid entry with a color.
### Constants
SkCanvas::Lattice::kDefault | 0 | Draws Bitmap into lattice rectangle.
|
SkCanvas::Lattice::kTransparent | 1 | Skips lattice rectangle by making it transparent.
|
SkCanvas::Lattice::kFixedColor | 2 | Draws one of fColors into lattice rectangle.
|
const int* fXDivs
Array of x-coordinates that divide the bitmap vertically.
Array entries must be unique, increasing, greater than or equal to
fBounds left edge, and less than fBounds right edge.
Set the first element to fBounds left to collapse the left column of
fixed grid entries.
const int* fYDivs
Array of y-coordinates that divide the bitmap horizontally.
Array entries must be unique, increasing, greater than or equal to
fBounds top edge, and less than fBounds bottom edge.
Set the first element to fBounds top to collapse the top row of fixed
grid entries.
const RectType* fRectTypes
Optional array of fill types, one per rectangular grid entry:
array length must be( fXCount + 1) * (fYCount + 1)
.
Each RectType is one of: kDefault, kTransparent, kFixedColor.
Array entries correspond to the rectangular grid entries, ascending
left to right and then top to bottom.
int fXCount
Number of entries in fXDivs array; one less than the number of
horizontal divisions.
int fYCount
Number of entries in fYDivs array; one less than the number of vertical
divisions.
const SkIRect* fBounds
Optional subset IRect source to draw from.
If nullptr, source bounds is dimensions of Bitmap or Image.
const SkColor* fColors
Optional array of colors, one per rectangular grid entry.
Array length must be( fXCount + 1) * (fYCount + 1)
.
Array entries correspond to the rectangular grid entries, ascending
left to right, then top to bottom.
## drawBitmapLattice
void drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice, const SkRect& dst,
const SkPaint* paint = nullptr)
Draw Bitmap bitmap stretched proportionally to fit into Rect dst.
Lattice lattice divides bitmap into a rectangular grid.
Each intersection of an even-numbered row and column is fixed; like the corners
of drawBitmapNine, fixed lattice elements never scale larger than their initial
size and shrink proportionately when all fixed elements exceed the bitmap
dimension. All other grid elements scale to fill the available space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp TileMode set replicates the bitmap edge color when it samples
outside of its bounds.
### Parameters
### Example
The two leftmost
bitmap draws has four corners and sides to the left and right of center.
The leftmost
bitmap draw scales the width of corners proportionately to fit.
The third and fourth draw corners are not scaled; the sides are scaled to
fill the remaining space; the center is transparent.
The rightmost
bitmap draw has four corners scaled vertically to fit, and uses sides above
and below center to fill the remaining space.
### See Also
drawImageLattice drawBitmap drawBitmapNine Lattice
---
## drawImageLattice
void drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
const SkPaint* paint = nullptr)
Draw Image image stretched proportionally to fit into Rect dst.
Lattice lattice divides image into a rectangular grid.
Each intersection of an even-numbered row and column is fixed; like the corners
of drawBitmapNine, fixed lattice elements never scale larger than their initial
size and shrink proportionately when all fixed elements exceed the bitmap
dimension. All other grid elements scale to fill the available space, if any.
Additionally transform draw using Clip, Matrix, and optional Paint paint.
If Paint paint is supplied, apply Color Filter, Color Alpha, Image Filter,
Blend Mode, and Draw Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask Filter, generate mask from bitmap bounds.
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp TileMode set replicates the bitmap edge color when it samples
outside of its bounds.
### Parameters
### Example
The leftmost
image is smaller than center; only corners are drawn, all scaled to fit.
The second
image equals the size of center; only corners are drawn without scaling.
The remaining images are larger than center. All corners draw without scaling. The sides
are scaled if needed to take up the remaining space; the center is transparent.
### See Also
drawBitmapLattice drawImage[2] drawImageNine[2] Lattice
---
## Draw Text
| name | description |
| --- | --- |
| drawPosText | draws text at array of (x, y) positions |
| drawPosTextH | draws text at x positions with common baseline |
| drawString | draws null terminated string at (x, y) using font advance |
| | drawString(const char* string, SkScalar x, SkScalar y, const SkPaint& paint) |
| | drawString(const SkString& string, SkScalar x, SkScalar y, const SkPaint& paint) |
| drawText | draws text at (x, y), using font advance |
| drawTextBlob | draws text with arrays of positions and Paint |
| | drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint) |
| | drawTextBlob(const sk sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint) |
| drawTextOnPath | draws text following Path contour |
| drawTextOnPathHV | draws text following Path with offsets |
| drawTextRSXform | draws text with array of RSXform |
## drawText
void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint)
Draw text, with origin at (x, y), using Clip, Matrix, and Paint paint.
text meaning depends on Paint Text Encoding; by default, text is encoded as
UTF-8.
x and y meaning depends on Paint Text Align and Paint Vertical Text; by default
text draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint Text Size.
All elements of paint: Path Effect, Mask Filter, Shader,
Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws
filled 12 point black Glyphs.
### Parameters
### Example
### See Also
drawString[2] drawPosText drawPosTextH drawTextBlob[2] drawTextOnPath drawTextRSXform
---
## drawString
void drawString(const char* string, SkScalar x, SkScalar y, const SkPaint& paint)
Draw null terminated string, with origin at (x, y), using Clip, Matrix, and
Paint paint. Note that this per-glyph xform does not affect the shader (if present)
on the paint, just the glyph's geometry.
string meaning depends on Paint Text Encoding; by default, strings are encoded
as UTF-8. Other values of Paint Text Encoding are unlikely to produce the desired
results, since zero bytes may be embedded in the string.
x and y meaning depends on Paint Text Align and Paint Vertical Text; by default
string draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint Text Size.
All elements of paint: Path Effect, Mask Filter, Shader,
Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws
filled 12 point black Glyphs.
### Parameters
string |
character code points or Glyphs drawn,
ending with a char value of zero |
x |
start of string on x-axis |
y |
start of string on y-axis |
paint |
text size, blend, color, and so on, used to draw |
### Example
### See Also
drawText drawPosText drawPosTextH drawTextBlob[2] drawTextOnPath drawTextRSXform
---
void drawString(const SkString& string, SkScalar x, SkScalar y, const SkPaint& paint)
Draw null terminated string, with origin at (x, y), using Clip, Matrix, and
Paint paint.
string meaning depends on Paint Text Encoding; by default, strings are encoded
as UTF-8. Other values of Paint Text Encoding are unlikely to produce the desired
results, since zero bytes may be embedded in the string.
x and y meaning depends on Paint Text Align and Paint Vertical Text; by default
string draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint Text Size.
All elements of paint: Path Effect, Mask Filter, Shader,
Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws
filled 12 point black Glyphs.
### Parameters
string |
character code points or Glyphs drawn,
ending with a char value of zero |
x |
start of string on x-axis |
y |
start of string on y-axis |
paint |
text size, blend, color, and so on, used to draw |
### Example
### See Also
drawText drawPosText drawPosTextH drawTextBlob[2] drawTextOnPath drawTextRSXform
---
## drawPosText
void drawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint& paint)
Draw each glyph in text with the origin in pos array, using Clip, Matrix, and
Paint paint. The number of entries in pos array must match the number of Glyphs
described by byteLength of text.
text meaning depends on Paint Text Encoding; by default, text is encoded as
UTF-8. pos elements' meaning depends on Paint Text Align and Paint Vertical Text;
by default each glyph left side bearing is positioned at x and its
baseline is positioned at y. Text size is affected by Matrix and
Paint Text Size.
All elements of paint: Path Effect, Mask Filter, Shader,
Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws
filled 12 point black Glyphs.
Layout engines such as Harfbuzz typically position each glyph
rather than using the font advance widths.
### Parameters
### Example
### See Also
drawText drawPosTextH drawTextBlob[2] drawTextOnPath drawTextRSXform
---
## drawPosTextH
void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY,
const SkPaint& paint)
Draw each glyph in text with its (x, y) origin composed from xpos array and
constY, using Clip, Matrix, and Paint paint. The number of entries in xpos array
must match the number of Glyphs described by byteLength of text.
text meaning depends on Paint Text Encoding; by default, text is encoded as
UTF-8. xpos elements' meaning depends on Paint Text Align and Paint Vertical Text;
by default each glyph left side bearing is positioned at an xpos element and
its baseline is positioned at constY. Text size is affected by Matrix and
Paint Text Size.
All elements of paint: Path Effect, Mask Filter, Shader,
Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws
filled 12 point black Glyphs.
Layout engines such as Harfbuzz typically position each glyph
rather than using the font advance widths if all Glyphs share the same
baseline.
### Parameters
text |
character code points or Glyphs drawn |
byteLength |
byte length of text array |
xpos |
array of x positions, used to position each glyph |
constY |
shared y coordinate for all of x positions |
paint |
text size, blend, color, and so on, used to draw |
### Example
### See Also
drawText drawPosText drawTextBlob[2] drawTextOnPath drawTextRSXform
---
## drawTextOnPathHV
void drawTextOnPathHV(const void* text, size_t byteLength, const SkPath& path, SkScalar hOffset,
SkScalar vOffset, const SkPaint& paint)
Draw text on Path path, using Clip, Matrix, and Paint paint.
Origin of text is at distance hOffset along the path, offset by a perpendicular
vector of length vOffset. If the path section corresponding the glyph advance is
curved, the glyph is drawn curved to match; control points in the glyph are
mapped to projected points parallel to the path. If the text advance is larger
than the path length, the excess text is clipped.
text meaning depends on Paint Text Encoding; by default, text is encoded as
UTF-8. Origin meaning depends on Paint Text Align and Paint Vertical Text; by
default text positions the first glyph left side bearing at origin x and its
baseline at origin y. Text size is affected by Matrix and Paint Text Size.
All elements of paint: Path Effect, Mask Filter, Shader,
Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws
filled 12 point black Glyphs.
### Parameters
### Example
### See Also
drawTextOnPath drawText drawPosTextH drawTextBlob[2] drawTextRSXform
---
## drawTextOnPath
void drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint)
Draw text on Path path, using Clip, Matrix, and Paint paint.
Origin of text is at beginning of path offset by matrix, if provided, before it
is mapped to path. If the path section corresponding the glyph advance is
curved, the glyph is drawn curved to match; control points in the glyph are
mapped to projected points parallel to the path. If the text advance is larger
than the path length, the excess text is clipped.
text meaning depends on Paint Text Encoding; by default, text is encoded as
UTF-8. Origin meaning depends on Paint Text Align and Paint Vertical Text; by
default text positions the first glyph left side bearing at origin x and its
baseline at origin y. Text size is affected by Matrix and Paint Text Size.
All elements of paint: Path Effect, Mask Filter, Shader,
Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws
filled 12 point black Glyphs.
### Parameters
### Example
### See Also
drawTextOnPathHV drawText drawPosTextH drawTextBlob[2] drawTextRSXform
---
## drawTextRSXform
void drawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
const SkRect* cullRect, const SkPaint& paint)
Draw text, transforming each glyph by the corresponding SkRSXform,
using Clip, Matrix, and Paint paint.
RSXform array specifies a separate square scale, rotation, and translation for
each glyph.
Optional Rect cullRect is a conservative bounds of text, taking into account
RSXform and paint. If cullRect is outside of Clip, canvas can skip drawing.
All elements of paint: Path Effect, Mask Filter, Shader,
Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws
filled 12 point black Glyphs.
### Parameters
### Example
### See Also
drawTextOnPath drawTextOnPathHV drawText drawPosText drawTextBlob[2]
---
## drawTextBlob
void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint)
Draw Text Blob blob at (x, y), using Clip, Matrix, and Paint paint.
blob contains Glyphs, their positions, and paint attributes specific to text:
Typeface, Paint Text Size, Paint Text Scale X, Paint Text Skew X,
Paint Text Align, Paint Hinting, Anti-alias, Paint Fake Bold,
Font Embedded Bitmaps, Full Hinting Spacing, LCD Text, Linear Text,
Subpixel Text, and Paint Vertical Text.
Paint Text Encoding must be set to SkPaint::kGlyphID TextEncoding.
Elements of paint: Path Effect, Mask Filter, Shader, Color Filter,
Image Filter, and Draw Looper; apply to blob.
### Parameters
blob |
Glyphs, positions, and their paints' text size, typeface, and so on |
x |
horizontal offset applied to blob |
y |
vertical offset applied to blob |
paint |
blend, color, stroking, and so on, used to draw |
### Example
### See Also
drawText drawPosText drawPosTextH
---
void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint)
Draw Text Blob blob at (x, y), using Clip, Matrix, and Paint paint.
blob contains Glyphs, their positions, and paint attributes specific to text:
Typeface, Paint Text Size, Paint Text Scale X, Paint Text Skew X,
Paint Text Align, Paint Hinting, Anti-alias, Paint Fake Bold,
Font Embedded Bitmaps, Full Hinting Spacing, LCD Text, Linear Text,
Subpixel Text, and Paint Vertical Text.
Paint Text Encoding must be set to SkPaint::kGlyphID TextEncoding.
Elements of paint: Path Effect, Mask Filter, Shader, Color Filter,
Image Filter, and Draw Looper; apply to blob.
### Parameters
blob |
Glyphs, positions, and their paints' text size, typeface, and so on |
x |
horizontal offset applied to blob |
y |
vertical offset applied to blob |
paint |
blend, color, stroking, and so on, used to draw |
### Example
### See Also
drawText drawPosText drawPosTextH
---
## drawPicture
void drawPicture(const SkPicture* picture)
Draw Picture picture, using Clip and Matrix.
Clip and Matrix are unchanged by picture contents, as if
save was called before and restore was called after drawPicture.
Picture records a series of draw commands for later playback.
### Parameters
picture |
recorded drawing commands to play |
### Example
### See Also
drawDrawable[2] SkPicture SkPicture::playback
---
void drawPicture(const sk_sp<SkPicture>& picture)
Draw Picture picture, using Clip and Matrix.
Clip and Matrix are unchanged by picture contents, as if
save was called before and restore was called after drawPicture.
Picture records a series of draw commands for later playback.
### Parameters
picture |
recorded drawing commands to play |
### Example
### See Also
drawDrawable[2] SkPicture SkPicture::playback
---
void drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint)
Draw Picture picture, using Clip and Matrix; transforming picture with
Matrix matrix, if provided; and use Paint paint Color Alpha, Color Filter,
Image Filter, and Blend Mode, if provided.
matrix transformation is equivalent to: save, concat, drawPicture, restore.
paint use is equivalent to: saveLayer, drawPicture, restore.
### Parameters
picture |
recorded drawing commands to play |
matrix |
Matrix to rotate, scale, translate, and so on; may be nullptr |
paint |
Paint to apply transparency, filtering, and so on; may be nullptr |
### Example
### See Also
drawDrawable[2] SkPicture SkPicture::playback
---
void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, const SkPaint* paint)
Draw Picture picture, using Clip and Matrix; transforming picture with
Matrix matrix, if provided; and use Paint paint Color Alpha, Color Filter,
Image Filter, and Blend Mode, if provided.
matrix transformation is equivalent to: save, concat, drawPicture, restore.
paint use is equivalent to: saveLayer, drawPicture, restore.
### Parameters
picture |
recorded drawing commands to play |
matrix |
Matrix to rotate, scale, translate, and so on; may be nullptr |
paint |
Paint to apply transparency, filtering, and so on; may be nullptr |
### Example
### See Also
drawDrawable[2] SkPicture SkPicture::playback
---
## drawVertices
void drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint)
Draw Vertices vertices, a triangle mesh, using Clip and Matrix.
If Vertices Texs and Vertices Colors are defined in vertices, and Paint paint
contains Shader, Blend Mode mode combines Vertices Colors with Shader.
### Parameters
### Example
### See Also
drawPatch[2] drawPicture[2][3][4]
---
void drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode, const SkPaint& paint)
Draw Vertices vertices, a triangle mesh, using Clip and Matrix.
If Vertices Texs and Vertices Colors are defined in vertices, and Paint paint
contains Shader, Blend Mode mode combines Vertices Colors with Shader.
### Parameters
### Example
### See Also
drawPatch[2] drawPicture[2][3][4]
---
## drawPatch
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4],
SkBlendMode mode, const SkPaint& paint)
Draws a Coons_Patch: the interpolation of four cubics with shared corners,
associating a color, and optionally a texture coordinate, with each corner.
Coons_Patch uses Clip and Matrix, paint Shader, Color Filter,
Color Alpha, Image Filter, and Blend Mode. If Shader is provided it is treated
as Coons_Patch texture; Blend Mode mode combines Color colors and Shader if
both are provided.
Point array cubics specifies four Cubics starting at the top-left corner,
in clockwise order, sharing every fourth point. The last 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.
### Parameters
### Example
### See Also
SeeAlso drawVertices[2] drawPicture[2][3][4]
---
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4],
const SkPaint& paint)
Draws Cubic Coons_Patch: the interpolation of four cubics with shared corners,
associating a color, and optionally a texture coordinate, with each corner.
Coons_Patch uses Clip and Matrix, paint Shader, Color Filter,
Color Alpha, Image Filter, and Blend Mode. If Shader is provided it is treated
as Coons_Patch texture; Blend Mode mode combines Color colors and Shader if
both are provided.
Point array cubics specifies four Cubics starting at the top-left corner,
in clockwise order, sharing every fourth point. The last 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.
### Parameters
### Example
### Example
### See Also
SeeAlso drawVertices[2] drawPicture[2][3][4]
---
## drawAtlas
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
const SkPaint* paint)
Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color Alpha, Color Filter, Image Filter, and Blend Mode
to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.
xform, text, and colors if present, must contain count entries.
Optional colors are applied for each sprite using Blend Mode.
Optional cullRect is a conservative bounds of all transformed sprites.
If cullRect is outside of Clip, canvas can skip drawing.
### Parameters
### Example
### See Also
drawBitmap drawImage[2]
---
void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
const SkPaint* paint)
Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color Alpha, Color Filter, Image Filter, and Blend Mode
to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.
xform, text, and colors if present, must contain count entries.
Optional colors is applied for each sprite using Blend Mode.
Optional cullRect is a conservative bounds of all transformed sprites.
If cullRect is outside of Clip, canvas can skip drawing.
### Parameters
### Example
### See Also
drawBitmap drawImage[2]
---
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count,
const SkRect* cullRect, const SkPaint* paint)
Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color Alpha, Color Filter, Image Filter, and Blend Mode
to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.
xform and text must contain count entries.
Optional cullRect is a conservative bounds of all transformed sprites.
If cullRect is outside of Clip, canvas can skip drawing.
### Parameters
### Example
### See Also
drawBitmap drawImage[2]
---
void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[], int count,
const SkRect* cullRect, const SkPaint* paint)
Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color Alpha, Color Filter, Image Filter, and Blend Mode
to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.
xform and text must contain count entries.
Optional cullRect is a conservative bounds of all transformed sprites.
If cullRect is outside of Clip, canvas can skip drawing.
### Parameters
### Example
### See Also
drawBitmap drawImage[2]
---
## drawDrawable
void drawDrawable(SkDrawable* drawable, const SkMatrix* matrix = nullptr)
Draw 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 SkDrawable::draw() can be called when the operation is finalized. To force
immediate drawing, call SkDrawable::draw() instead.
### Parameters
drawable |
custom struct encapsulating drawing commands |
matrix |
transformation applied to drawing; may be nullptr |
### Example
### See Also
SkDrawable drawPicture[2][3][4]
---
void drawDrawable(SkDrawable* drawable, SkScalar x, SkScalar y)
Draw 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 SkDrawable::draw() can be called when the operation is finalized. To force
immediate drawing, call SkDrawable::draw() instead.
### Parameters
drawable |
custom struct encapsulating drawing commands |
x |
offset into Canvas writable pixels in x |
y |
offset into Canvas writable pixels in y |
### Example
### See Also
SkDrawable drawPicture[2][3][4]
---
## drawAnnotation
void drawAnnotation(const SkRect& rect, const char key[], SkData* value)
Associate Rect on Canvas with an annotation; a key-value pair, where the key is
a null-terminated utf8 string, and optional value is stored as Data.
Only some canvas implementations, such as recording to Picture, or drawing to
Document PDF, use annotations.
### Parameters
rect |
Rect extent of canvas to annotate |
key |
string used for lookup |
value |
data holding value stored in annotation |
### Example
### See Also
SkPicture SkDocument
---
void drawAnnotation(const SkRect& rect, const char key[], const sk_sp<SkData>& value)
Associate Rect on Canvas when an annotation; a key-value pair, where the key is
a null-terminated utf8 string, and optional value is stored as Data.
Only some canvas implementations, such as recording to Picture, or drawing to
Document PDF, use annotations.
### Parameters
rect |
Rect extent of canvas to annotate |
key |
string used for lookup |
value |
data holding value stored in annotation |
### Example
### See Also
SkPicture SkDocument
---
## getDrawFilter
SkDrawFilter* getDrawFilter() const
soon
---
## setDrawFilter
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter)
soon
---
## isClipEmpty
virtual bool isClipEmpty() const
Returns true if Clip is empty; that is, nothing will draw.
May do work when called; it should not be called
more often than needed. However, once called, subsequent calls perform no
work until Clip changes.
### Return Value
true if Clip is empty
### Example
#### Example Output
~~~~
clip is not empty
clip is empty
~~~~
### See Also
isClipRect getLocalClipBounds[2] getDeviceClipBounds[2]
---
## isClipRect
virtual bool isClipRect() const
Returns true if Clip is Rect and not empty.
Returns false if the clip is empty, or if it is not Rect.
### Return Value
true if Clip is Rect and not empty
### Example
#### Example Output
~~~~
clip is rect
clip is not rect
~~~~
### See Also
isClipEmpty getLocalClipBounds[2] getDeviceClipBounds[2]
---