Hal Canary | 6c8422c | 2020-01-10 15:22:09 -0500 | [diff] [blame] | 1 | // Copyright 2020 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(dither1, 256, 100, false, 0) { |
| 5 | void draw(SkCanvas* canvas) { |
| 6 | SkBitmap bm16; |
| 7 | bm16.allocPixels(SkImageInfo::Make(32, 32, kRGB_565_SkColorType, kOpaque_SkAlphaType)); |
| 8 | SkCanvas c16(bm16); |
| 9 | SkPaint colorPaint; |
| 10 | for (auto dither : {false, true}) { |
| 11 | colorPaint.setDither(dither); |
| 12 | for (auto colors : {0xFF333333, 0xFF666666, 0xFF999999, 0xFFCCCCCC}) { |
| 13 | for (auto mask : {0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF}) { |
| 14 | colorPaint.setColor(colors & mask); |
| 15 | c16.drawRect({0, 0, 8, 4}, colorPaint); |
| 16 | c16.translate(8, 0); |
| 17 | } |
| 18 | c16.translate(-32, 4); |
| 19 | } |
| 20 | } |
| 21 | canvas->scale(8, 8); |
Mike Reed | ecdd979 | 2021-01-27 20:39:22 -0500 | [diff] [blame] | 22 | canvas->drawImage(bm16.asImage(), 0, 0); |
Hal Canary | 6c8422c | 2020-01-10 15:22:09 -0500 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | } // END FIDDLE |