Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / docs / examples / skcanvas_paint.cpp
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"
4 REG_FIDDLE(skcanvas_paint, 256, 256, false, 5) {
5 void draw(SkCanvas* canvas) {
6     canvas->drawColor(SK_ColorWHITE);
7
8     SkPaint paint;
9     paint.setStyle(SkPaint::kStroke_Style);
10     paint.setStrokeWidth(4);
11     paint.setColor(SK_ColorRED);
12
13     SkRect rect = SkRect::MakeXYWH(50, 50, 40, 60);
14     canvas->drawRect(rect, paint);
15
16     SkRRect oval;
17     oval.setOval(rect);
18     oval.offset(40, 60);
19     paint.setColor(SK_ColorBLUE);
20     canvas->drawRRect(oval, paint);
21
22     paint.setColor(SK_ColorCYAN);
23     canvas->drawCircle(180, 50, 25, paint);
24
25     rect.offset(80, 0);
26     paint.setColor(SK_ColorYELLOW);
27     canvas->drawRoundRect(rect, 10, 10, paint);
28
29     SkPath path;
30     path.cubicTo(768, 0, -512, 256, 256, 256);
31     paint.setColor(SK_ColorGREEN);
32     canvas->drawPath(path, paint);
33
34     canvas->drawImage(image, 128, 128, SkSamplingOptions(), &paint);
35
36     SkRect rect2 = SkRect::MakeXYWH(0, 0, 40, 60);
37     canvas->drawImageRect(image, rect2, SkSamplingOptions(), &paint);
38
39     SkPaint paint2;
40     auto text = SkTextBlob::MakeFromString("Hello, Skia!", SkFont(nullptr, 18));
41     canvas->drawTextBlob(text.get(), 50, 25, paint2);
42 }
43 }  // END FIDDLE