| 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 |
REG_FIDDLE(Canvas_drawRRect, 256, 256, false, 0) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
SkPaint paint; |
| 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 |