1cb93a386Sopenharmony_ci// Copyright 2020 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_ciREG_FIDDLE(draw_patch, 350, 350, false, 6) {
5cb93a386Sopenharmony_ci// draw_patch
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    canvas->clear(SK_ColorWHITE);
8cb93a386Sopenharmony_ci    SkPaint p;
9cb93a386Sopenharmony_ci    p.setAntiAlias(true);
10cb93a386Sopenharmony_ci    const SkColor colors[] = {SK_ColorRED,     SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE,
11cb93a386Sopenharmony_ci                              SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW};
12cb93a386Sopenharmony_ci    const SkPoint pts[] = {{100.f / 4.f, 0.f}, {3.f * 100.f / 4.f, 100.f}};
13cb93a386Sopenharmony_ci    p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
14cb93a386Sopenharmony_ci                                             SkTileMode::kMirror));
15cb93a386Sopenharmony_ci    const SkPoint cubics[] = {{100, 100}, {150, 50},  {250, 150}, {300, 100},
16cb93a386Sopenharmony_ci                              {250, 150}, {350, 250}, {300, 300}, {250, 250},
17cb93a386Sopenharmony_ci                              {150, 350}, {100, 300}, {50, 250},  {150, 150}};
18cb93a386Sopenharmony_ci    const SkPoint texCoords[] = {
19cb93a386Sopenharmony_ci            {0.0f, 0.0f}, {100.0f, 0.0f}, {100.0f, 100.0f}, {0.0f, 100.0f}};
20cb93a386Sopenharmony_ci    canvas->drawPatch(cubics, nullptr, texCoords, SkBlendMode::kSrcOver, p);
21cb93a386Sopenharmony_ci}
22cb93a386Sopenharmony_ci}  // END FIDDLE
23