Flutter Engine
The Flutter Engine
Canvas_drawRRect.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(Canvas_drawRRect, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
7 paint.setAntiAlias(true);
8 SkRect outer = {30, 40, 210, 220};
9 SkRect radii = {30, 50, 70, 90 };
10 SkRRect rRect;
11 rRect.setNinePatch(outer, radii.fLeft, radii.fTop, radii.fRight, radii.fBottom);
12 canvas->drawRRect(rRect, paint);
13 paint.setColor(SK_ColorWHITE);
14 canvas->drawLine(outer.fLeft + radii.fLeft, outer.fTop,
15 outer.fLeft + radii.fLeft, outer.fBottom, paint);
16 canvas->drawLine(outer.fRight - radii.fRight, outer.fTop,
17 outer.fRight - radii.fRight, outer.fBottom, paint);
18 canvas->drawLine(outer.fLeft, outer.fTop + radii.fTop,
19 outer.fRight, outer.fTop + radii.fTop, paint);
20 canvas->drawLine(outer.fLeft, outer.fBottom - radii.fBottom,
21 outer.fRight, outer.fBottom - radii.fBottom, paint);
22}
23} // END FIDDLE
REG_FIDDLE(Canvas_drawRRect, 256, 256, false, 0)
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
void setNinePatch(const SkRect &rect, SkScalar leftRad, SkScalar topRad, SkScalar rightRad, SkScalar bottomRad)
Definition: SkRRect.cpp:115
const Paint & paint
Definition: color_source.cc:38
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15