1 // 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"
4 REG_FIDDLE(setimagefilter, 256, 100, false, 0) {
draw(SkCanvas * canvas)5 void 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);
15     paint.setImageFilter(SkImageFilters::PointLitDiffuse(
16             SkPoint3::Make(80, 100, 10), SK_ColorWHITE, 1, 2, nullptr, nullptr));
17     canvas->drawImage(bitmap.asImage(), 0, 0, SkSamplingOptions(), &paint);
18 }
19 
20 }  // END FIDDLE
21