blob: 80754d1f405498125d867fb3cb96800de3716203 [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=8b26507690b71462f44642b911890bbf
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Dither_a, 256, 256, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void 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