blob: bfd55f458295249c07fde91f5156d61d7d6016d0 [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// 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"
4REG_FIDDLE(dither1, 256, 100, false, 0) {
5void 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 Reedecdd9792021-01-27 20:39:22 -050022 canvas->drawImage(bm16.asImage(), 0, 0);
Hal Canary6c8422c2020-01-10 15:22:09 -050023}
24
25} // END FIDDLE