blob: f38f4036217710b5b43d91f51fca85c08a59babe [file] [log] [blame]
Brian Salomon65749212017-12-01 16:01:47 -05001/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
9#include "include/core/SkCanvas.h"
10#include "include/core/SkPaint.h"
11#include "include/core/SkRRect.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040012#include "include/core/SkRect.h"
13#include "include/core/SkScalar.h"
14
15#include <initializer_list>
Brian Salomon65749212017-12-01 16:01:47 -050016
17DEF_SIMPLE_GM(drrect_small_inner, canvas, 170, 610) {
18 SkPaint paint;
19 paint.setAntiAlias(true);
20 static constexpr SkScalar kOuterRadius = 35.f;
21 auto outer = SkRRect::MakeOval(SkRect::MakeXYWH(0, 0, 2 * kOuterRadius, 2 * kOuterRadius));
22 canvas->translate(10.f, 10.f);
23 canvas->save();
24 for (bool offcenter : {false, true}) {
25 for (bool oval : {false, true}) {
26 for (SkScalar innerRadiusX : {1.f, 0.5f, 0.1f, .01f}) {
27 SkScalar innerRadiusY = innerRadiusX;
28 if (oval) {
29 innerRadiusY *= 0.95f;
30 }
31 SkScalar tx = kOuterRadius - innerRadiusX;
32 SkScalar ty = kOuterRadius - innerRadiusY;
33 if (offcenter) {
34 tx += 1.f;
35 }
36 auto inner = SkRRect::MakeOval(
37 SkRect::MakeXYWH(tx, ty, 2 * innerRadiusX, 2 * innerRadiusY));
38 canvas->drawDRRect(outer, inner, paint);
39 canvas->translate(0, 2 * kOuterRadius + 5);
40 }
41 }
42 canvas->restore();
43 canvas->translate(2 * kOuterRadius + 2, 0);
44 }
45 canvas->restore();
46}