blob: 01cb7e6f5706e2240a9426eb8e81e9e9a3cde0a3 [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=76d4d4a7931a48495e4d5f54e073be53
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Dither_b, 256, 256, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 canvas->clear(0);
8 SkBitmap bm32;
9 bm32.allocPixels(SkImageInfo::Make(20, 10, kN32_SkColorType, kPremul_SkAlphaType));
10 SkCanvas c32(bm32);
11 SkPoint points[] = {{0, 0}, {20, 0}};
12 SkColor colors[] = {0xFF334455, 0xFF662211 };
13 SkPaint paint;
14 paint.setShader(SkGradientShader::MakeLinear(
15 points, colors, nullptr, SK_ARRAY_COUNT(colors),
Mike Reedfae8fce2019-04-03 10:27:45 -040016 SkTileMode::kClamp));
Hal Canary87515122019-03-15 14:22:51 -040017 paint.setDither(true);
18 c32.drawPaint(paint);
19 canvas->scale(12, 12);
20 canvas->drawBitmap(bm32, 0, 0);
21 paint.setBlendMode(SkBlendMode::kPlus);
22 canvas->drawBitmap(bm32, 0, 11, &paint);
23 canvas->drawBitmap(bm32, 0, 11, &paint);
24 canvas->drawBitmap(bm32, 0, 11, &paint);
25}
26} // END FIDDLE