1 // Copyright 2019 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 // HASH=c015dc2010c15e1c00b4f7330232b0f7
5 REG_FIDDLE(Shader_Methods_a, 256, 256, false, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7 SkPaint paint;
8 SkPoint center = { 50, 50 };
9 SkScalar radius = 50;
10 const SkColor colors[] = { 0xFFFFFFFF, 0xFF000000 };
11 paint.setShader(SkGradientShader::MakeRadial(center, radius, colors,
12 nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp));
13 for (SkScalar a : { 0.3f, 0.6f, 1.0f } ) {
14 paint.setAlpha((int) (a * 255));
15 canvas->drawCircle(center.fX, center.fY, radius, paint);
16 canvas->translate(70, 70);
17 }
18 }
19 } // END FIDDLE
20