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) {
7 paint.setAntiAlias(true);
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);
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);
22 void draw(SkCanvas* canvas) {
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);