xref: /third_party/skia/docs/examples/Canvas_drawOval.cpp (revision cb93a386)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/skia/docs/examples/
1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=8b6b86f8a022811cd29a9c6ab771df12
5cb93a386Sopenharmony_ciREG_FIDDLE(Canvas_drawOval, 256, 256, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    canvas->clear(0xFF3f5f9f);
8cb93a386Sopenharmony_ci    SkColor  kColor1 = SkColorSetARGB(0xff, 0xff, 0x7f, 0);
9cb93a386Sopenharmony_ci    SkColor  g1Colors[] = { kColor1, SkColorSetA(kColor1, 0x20) };
10cb93a386Sopenharmony_ci    SkPoint  g1Points[] = { { 0, 0 }, { 0, 100 } };
11cb93a386Sopenharmony_ci    SkScalar pos[] = { 0.2f, 1.0f };
12cb93a386Sopenharmony_ci    SkRect bounds = SkRect::MakeWH(80, 70);
13cb93a386Sopenharmony_ci    SkPaint paint;
14cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
15cb93a386Sopenharmony_ci    paint.setShader(SkGradientShader::MakeLinear(g1Points, g1Colors, pos, SK_ARRAY_COUNT(g1Colors),
16cb93a386Sopenharmony_ci            SkTileMode::kClamp));
17cb93a386Sopenharmony_ci    canvas->drawOval(bounds , paint);
18cb93a386Sopenharmony_ci}
19cb93a386Sopenharmony_ci}  // END FIDDLE
20

Indexes created Thu Nov 07 10:32:03 CST 2024