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(Anti_Alias, 512, 256, false, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 SkBitmap bitmap;
7 bitmap.allocN32Pixels(50, 50);
8 SkCanvas offscreen(bitmap);
9 SkPaint paint;
10 paint.setStyle(SkPaint::kStroke_Style);
11 paint.setStrokeWidth(10);
12 for (bool antialias : { false, true }) {
13 paint.setColor(antialias ? SK_ColorRED : SK_ColorBLUE);
14 paint.setAntiAlias(antialias);
15 bitmap.eraseColor(0);
16 offscreen.drawLine(5, 5, 15, 30, paint);
17 canvas->drawLine(5, 5, 15, 30, paint);
18 canvas->save();
19 canvas->scale(10, 10);
20 canvas->drawImage(bitmap.asImage(), antialias ? 12 : 0, 0);
21 canvas->restore();
22 canvas->translate(15, 0);
23 }
24 }
25 } // END FIDDLE
26