blob: acd850aa64f63e77463be2f01f6d11c94edf6a20 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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 "fiddle/examples.h"
4// HASH=c4620df2eaba447b581688d3100053b1
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(RRect_setNinePatch, 256, 70, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void 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