Hal Canary | 6c8422c | 2020-01-10 15:22:09 -0500 | [diff] [blame] | 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 |
| 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 | |
Mike Reed | b86cd3d | 2020-12-10 14:55:43 -0500 | [diff] [blame] | 18 | p.setShader(image->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, SkSamplingOptions())); |
Hal Canary | 6c8422c | 2020-01-10 15:22:09 -0500 | [diff] [blame] | 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 |