blob: d9b606f22dddc1042a55361a8d290ba9538a406a [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=862cc026601a41a58df49c0b9f0d7777
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Clip, 256, 90, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 SkPaint redPaint, scalePaint;
8 redPaint.setAntiAlias(true);
9 redPaint.setColor(SK_ColorRED);
10 canvas->save();
11 for (bool antialias : { false, true } ) {
12 canvas->save();
13 canvas->clipRect(SkRect::MakeWH(19.5f, 11.5f), antialias);
14 canvas->drawCircle(17, 11, 8, redPaint);
15 canvas->restore();
16 canvas->translate(16, 0);
17 }
18 canvas->restore();
19 SkMatrix matrix;
20 matrix.setScale(6, 6);
21 scalePaint.setImageFilter(
Mike Reed92236652021-02-01 13:07:32 -050022 SkImageFilters::MatrixTransform(matrix, SkSamplingOptions(), nullptr));
Hal Canary87515122019-03-15 14:22:51 -040023 SkCanvas::SaveLayerRec saveLayerRec(
24 nullptr, &scalePaint, SkCanvas::kInitWithPrevious_SaveLayerFlag);
25 canvas->saveLayer(saveLayerRec);
26 canvas->restore();
27}
28} // END FIDDLE