xref: /third_party/skia/docs/examples/shapes.cpp (revision cb93a386)
1// Copyright 2020 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"
4REG_FIDDLE_ANIMATED(shapes, 256, 256, false, 5, 0) {
5void draw(SkCanvas* canvas) {
6    canvas->drawColor(SK_ColorWHITE);
7
8    SkPaint paint;
9    paint.setStyle(SkPaint::kFill_Style);
10    paint.setAntiAlias(true);
11    paint.setStrokeWidth(4);
12    paint.setColor(0xff4285F4);
13
14    SkRect rect = SkRect::MakeXYWH(10, 10, 100, 160);
15    canvas->drawRect(rect, paint);
16
17    SkRRect oval;
18    oval.setOval(rect);
19    oval.offset(40, 80);
20    paint.setColor(0xffDB4437);
21    canvas->drawRRect(oval, paint);
22
23    paint.setColor(0xff0F9D58);
24    canvas->drawCircle(180, 50, 25, paint);
25
26    rect.offset(80, 50);
27    paint.setColor(0xffF4B400);
28    paint.setStyle(SkPaint::kStroke_Style);
29    canvas->drawRoundRect(rect, 10, 10, paint);
30}
31}  // END FIDDLE
32