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