blob: 589a0edb7d17bdb808998c5286ab26dea7001632 [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(setimagefilter, 256, 100, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkBitmap bitmap;
7 bitmap.allocN32Pixels(100, 100);
8 SkCanvas offscreen(bitmap);
9 SkPaint paint;
10 paint.setAntiAlias(true);
11 paint.setColor(SK_ColorWHITE);
12 SkFont font(nullptr, 96);
13 offscreen.clear(0);
14 offscreen.drawString("e", 20, 70, font, paint);
Michael Ludwiged552f82021-01-22 13:01:26 -050015 paint.setImageFilter(SkImageFilters::PointLitDiffuse(
Hal Canary6c8422c2020-01-10 15:22:09 -050016 SkPoint3::Make(80, 100, 10), SK_ColorWHITE, 1, 2, nullptr, nullptr));
Mike Reedecdd9792021-01-27 20:39:22 -050017 canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
Hal Canary6c8422c2020-01-10 15:22:09 -050018}
19
20} // END FIDDLE