1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=c4620df2eaba447b581688d3100053b1
5cb93a386Sopenharmony_ciREG_FIDDLE(RRect_setNinePatch, 256, 70, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    SkPaint paint;
8cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
9cb93a386Sopenharmony_ci    SkRRect rrect;
10cb93a386Sopenharmony_ci    rrect.setNinePatch({30, 10, 100, 60}, 10, 20, 20, 10);
11cb93a386Sopenharmony_ci    canvas->drawRRect(rrect, paint);
12cb93a386Sopenharmony_ci    paint.setColor(SK_ColorWHITE);
13cb93a386Sopenharmony_ci    const SkRect r = rrect.getBounds();
14cb93a386Sopenharmony_ci    canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
15cb93a386Sopenharmony_ci                     r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
16cb93a386Sopenharmony_ci    canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
17cb93a386Sopenharmony_ci                     r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
18cb93a386Sopenharmony_ci    canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
19cb93a386Sopenharmony_ci                     r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
20cb93a386Sopenharmony_ci    canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
21cb93a386Sopenharmony_ci                     r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
22cb93a386Sopenharmony_ci}
23cb93a386Sopenharmony_ci}  // END FIDDLE
24