1 // 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.
3 #include "tools/fiddle/examples.h"
4 REG_FIDDLE(Canvas_drawPicture_2, 256, 256, false, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 SkPictureRecorder recorder;
7 SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
8 for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xff007f00 } ) {
9 SkPaint paint;
10 paint.setColor(color);
11 recordingCanvas->drawRect({10, 10, 30, 40}, paint);
12 recordingCanvas->translate(10, 10);
13 recordingCanvas->scale(1.2f, 1.4f);
14 }
15 sk_sp<SkPicture> playback = recorder.finishRecordingAsPicture();
16 canvas->drawPicture(playback);
17 canvas->scale(2, 2);
18 canvas->translate(50, 0);
19 canvas->drawPicture(playback);
20 }
21 } // END FIDDLE
22