Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [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. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=8b26507690b71462f44642b911890bbf |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Dither_a, 256, 256, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | SkBitmap bm16; |
| 8 | bm16.allocPixels(SkImageInfo::Make(32, 32, kRGB_565_SkColorType, kOpaque_SkAlphaType)); |
| 9 | SkCanvas c16(bm16); |
| 10 | SkPaint colorPaint; |
| 11 | for (auto dither : { false, true } ) { |
| 12 | colorPaint.setDither(dither); |
| 13 | for (auto colors : { 0xFF333333, 0xFF666666, 0xFF999999, 0xFFCCCCCC } ) { |
| 14 | for (auto mask : { 0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF } ) { |
| 15 | colorPaint.setColor(colors & mask); |
| 16 | c16.drawRect({0, 0, 8, 4}, colorPaint); |
| 17 | c16.translate(8, 0); |
| 18 | } |
| 19 | c16.translate(-32, 4); |
| 20 | } |
| 21 | } |
| 22 | canvas->scale(8, 8); |
| 23 | canvas->drawBitmap(bm16, 0, 0); |
| 24 | } |
| 25 | } // END FIDDLE |