blob: 1ebe48e3ef788d1d40d6013043db15860015b16f [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// 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"
4REG_FIDDLE(draw_vertices, 256, 256, false, 6) {
5// draw_vertices
6void 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));
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