Hal Canary | 83c2f70 | 2019-03-07 14:53:03 -0500 | [diff] [blame] | 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 "fiddle/examples.h" |
| 4 | // HASH=fe80fd80b98a20823db7fb9a077243c7 |
| 5 | REG_FIDDLE(Paint_063, 256, 256, false, 0) { |
| 6 | void 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); |
| 12 | paint.setShader(SkShader::MakeBitmapShader(bitmap, |
| 13 | SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)); |
| 14 | for (SkColor c : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) { |
| 15 | paint.setColor(c); // all components in color affect shader |
| 16 | canvas->drawCircle(50, 50, 50, paint); |
| 17 | canvas->translate(70, 70); |
| 18 | } |
| 19 | } |
| 20 | } // END FIDDLE |