Debian Codegraph @

docs/examples/Shader_Methods_b.cpp

raw
1 // Copyright 2019 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(Shader_Methods_b, 256, 256, false, 0) {
5 void draw(SkCanvas* canvas) {
6 SkPaint paint;
7 SkBitmap bitmap;
8 uint8_t pixels[5] = { 0x22, 0x55, 0x88, 0xBB, 0xFF };
9 bitmap.installPixels(SkImageInfo::MakeA8(5, 1), pixels, 5); // bitmap only contains alpha
10 paint.setShader(bitmap.makeShader(SkTileMode::kMirror, SkTileMode::kMirror,
11 SkSamplingOptions()));
12 for (SkColor c : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
13 paint.setColor(c); // all components in color affect shader
14 canvas->drawCircle(50, 50, 50, paint);
15 canvas->translate(70, 70);
16 }
17 }
18 } // END FIDDLE