Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / docs / examples / Octopus_Generator.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(Octopus_Generator, 256, 256, false, 0) {
5 void paintOctopus(int x, int y, int size_base, SkColor color, SkCanvas* canvas) {
6     SkPaint paint;
7     paint.setAntiAlias(true);
8     paint.setColor(color);
9     int radius = 3 * size_base;
10     canvas->drawCircle(x, y, radius, paint);
11     for (int leg = 0; leg < 8; ++leg) {
12         canvas->drawCircle(x - radius + (2 * radius / 7.5 * leg),
13                            y + radius - pow(abs(4 - leg), 2), size_base / 2 + 2, paint);
14     }
15     paint.setColor(SkColorSetRGB(std::min(255u, SkColorGetR(color) + 20),
16                                  std::min(255u, SkColorGetG(color) + 20),
17                                  std::min(255u, SkColorGetB(color) + 20)));
18     canvas->drawCircle(x - size_base, y + size_base, size_base / 2, paint);
19     canvas->drawCircle(x + size_base, y + size_base, size_base / 2, paint);
20 }
21
22 void draw(SkCanvas* canvas) {
23     SkRandom rand;
24
25     for (int i = 0; i < 400; ++i) {
26         paintOctopus(rand.nextRangeScalar(0, 256), rand.nextRangeScalar(0, 256),
27                      rand.nextRangeScalar(6, 12), rand.nextU() | 0xFF0000000, canvas);
28     }
29 }
30 }  // END FIDDLE