Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(593)

Unified Diff: gm/bubbles.cpp

Issue 2004173002: Add bubbles GM for drawing/blending 50 circles. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/bubbles.cpp
diff --git a/gm/bubbles.cpp b/gm/bubbles.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..86c3daa661e27b254cb3e715d062a18265bd9401
--- /dev/null
+++ b/gm/bubbles.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 Google, Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+
+/*
+ * Draw 50 semi-transparent circles with pseudo-random positions, radii, and
+ * colors, using the default blend mode (SRC OVER). Use of SkRandom with
+ * default seed means results SHOULD be identical across multiple platforms.
+ */
+DEF_SIMPLE_GM(bubbles, canvas, 512, 512) {
+ canvas->clear(SK_ColorWHITE);
+
+ SkPaint p;
+ p.setAntiAlias(true);
+
+ SkRandom rand;
+
+ auto pos_min = SkIntToScalar(0);
+ auto pos_max = SkIntToScalar(511);
+ auto radius_min = SkIntToScalar(0);
+ auto radius_max = SkIntToScalar(128);
+ auto color_min = SkIntToScalar(0);
+ auto color_max = SkIntToScalar(255);
+
+ const int NUM_BUBBLES = 50;
+ for (int i = 0; i < NUM_BUBBLES; i++) {
+ auto cx = rand.nextRangeScalar(pos_min, pos_max);
+ auto cy = rand.nextRangeScalar(pos_min, pos_max);
+ auto radius = rand.nextRangeScalar(radius_min, radius_max);
+
+ auto a = (U8CPU)128;
+ auto r = (U8CPU)rand.nextRangeScalar(color_min, color_max);
+ auto g = (U8CPU)rand.nextRangeScalar(color_min, color_max);
+ auto b = (U8CPU)rand.nextRangeScalar(color_min, color_max);
+ p.setColor(SkColorSetARGB(a, r, g, b));
+
+ canvas->drawCircle(cx, cy, radius, p);
+ }
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698