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_vertices, 256, 256, false, 6) {
5 // draw_vertices
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7     SkPaint p;
8     p.setAntiAlias(true);
9 
10     SkPoint pts[3] = {{64, 32}, {0, 224}, {128, 224}};
11     SkColor colors[3] = {SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN};
12     canvas->drawVertices(
13             SkVertices::MakeCopy(SkVertices::kTriangles_VertexMode, 3, pts, nullptr, colors),
14             SkBlendMode::kSrcOver, p);
15 
16     canvas->translate(120, 0);
17 
18     p.setShader(image->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, SkSamplingOptions()));
19     SkPoint texs[3] = {{0, 0}, {0, 128}, {64, 256}};
20     canvas->drawVertices(
21             SkVertices::MakeCopy(SkVertices::kTriangles_VertexMode, 3, pts, texs, nullptr),
22             SkBlendMode::kSrcOver, p);
23 }
24 }  // END FIDDLE
25