skia2/docs/examples/Canvas_drawVertices_2.cpp
Mike Reed fae8fceb4a Use SkTileMode instead of nested enum
Add guard to transition clients

Change-Id: Ia7a3e8f95722f91e84af262168dadf89a78707da
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205720
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
2019-04-03 15:24:18 +00:00

17 lines
858 B
C++

// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "fiddle/examples.h"
// HASH=e8bdae9bea3227758989028424fcac3d
REG_FIDDLE(Canvas_drawVertices_2, 256, 256, false, 0) {
void draw(SkCanvas* canvas) {
SkPaint paint;
SkPoint points[] = { { 0, 0 }, { 250, 0 }, { 100, 100 }, { 0, 250 } };
SkPoint texs[] = { { 0, 0 }, { 0, 250 }, { 250, 250 }, { 250, 0 } };
SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN };
paint.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 4, SkTileMode::kClamp));
auto vertices = SkVertices::MakeCopy(SkVertices::kTriangleFan_VertexMode,
SK_ARRAY_COUNT(points), points, texs, colors);
canvas->drawVertices(vertices, SkBlendMode::kDarken, paint);
}
} // END FIDDLE