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.
3 #include "tools/fiddle/examples.h"
4 // HASH=c4620df2eaba447b581688d3100053b1
5 REG_FIDDLE(RRect_setNinePatch, 256, 70, false, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7     SkPaint paint;
8     paint.setAntiAlias(true);
9     SkRRect rrect;
10     rrect.setNinePatch({30, 10, 100, 60}, 10, 20, 20, 10);
11     canvas->drawRRect(rrect, paint);
12     paint.setColor(SK_ColorWHITE);
13     const SkRect r = rrect.getBounds();
14     canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
15                      r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
16     canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
17                      r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
18     canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
19                      r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
20     canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
21                      r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
22 }
23 }  // END FIDDLE
24