blob: 6df1d885190e28074979c095c236c4b4586e74d0 [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(skpaint_color_table_filter, 256, 256, false, 3) {
5void draw(SkCanvas* canvas) {
6 canvas->scale(0.5, 0.5);
7 uint8_t ct[256];
8 for (int i = 0; i < 256; ++i) {
9 int x = (i - 96) * 255 / 64;
10 ct[i] = x < 0 ? 0 : x > 255 ? 255 : x;
11 }
12 SkPaint paint;
13 paint.setColorFilter(SkTableColorFilter::MakeARGB(nullptr, ct, ct, ct));
14 canvas->drawImage(image, 0, 0, &paint);
15}
16} // END FIDDLE