• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "tools/fiddle/examples.h"
4 // HASH=8b26507690b71462f44642b911890bbf
5 REG_FIDDLE(Dither_a, 256, 256, false, 0) {
draw(SkCanvas * canvas)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->drawImage(bm16.asImage(), 0, 0);
24 }
25 }  // END FIDDLE
26