Flutter Engine
The Flutter Engine
Functions
drrect_small_inner.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include <initializer_list>

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (drrect_small_inner, canvas, 170, 610)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( drrect_small_inner  ,
canvas  ,
170  ,
610   
)

Definition at line 17 of file drrect_small_inner.cpp.

17 {
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}
static SkRRect MakeOval(const SkRect &oval)
Definition: SkRRect.h:162
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
SkRect oval
Definition: SkRecords.h:249
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659