blob: 1b63493e814a406d3afd37b95e9721b00af43dcb [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=fe80fd80b98a20823db7fb9a077243c7
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Shader_Methods_b, 256, 256, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 SkPaint paint;
8 SkBitmap bitmap;
9 bitmap.setInfo(SkImageInfo::MakeA8(5, 1), 5); // bitmap only contains alpha
10 uint8_t pixels[5] = { 0x22, 0x55, 0x88, 0xBB, 0xFF };
11 bitmap.setPixels(pixels);
Mike Reed50acf8f2019-04-08 13:20:23 -040012 paint.setShader(bitmap.makeShader(SkTileMode::kMirror, SkTileMode::kMirror));
Hal Canary87515122019-03-15 14:22:51 -040013 for (SkColor c : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
14 paint.setColor(c); // all components in color affect shader
15 canvas->drawCircle(50, 50, 50, paint);
16 canvas->translate(70, 70);
17 }
18}
19} // END FIDDLE