blob: 0f80eee03166de6ac1261e7f75e478199a28b901 [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.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// 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