1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=c7bb6248e4735b8d1a32d02fba40d344
5cb93a386Sopenharmony_ciREG_FIDDLE(Paint_setStyle, 256, 256, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    SkPaint paint;
8cb93a386Sopenharmony_ci    paint.setStrokeWidth(5);
9cb93a386Sopenharmony_ci    SkRegion region;
10cb93a386Sopenharmony_ci    region.op({140, 10, 160, 30}, SkRegion::kUnion_Op);
11cb93a386Sopenharmony_ci    region.op({170, 40, 190, 60}, SkRegion::kUnion_Op);
12cb93a386Sopenharmony_ci    SkBitmap bitmap;
13cb93a386Sopenharmony_ci    bitmap.setInfo(SkImageInfo::MakeA8(50, 50), 50);
14cb93a386Sopenharmony_ci    uint8_t pixels[50][50];
15cb93a386Sopenharmony_ci    for (int x = 0; x < 50; ++x) {
16cb93a386Sopenharmony_ci        for (int y = 0; y < 50; ++y) {
17cb93a386Sopenharmony_ci            pixels[y][x] = (x + y) % 5 ? 0xFF : 0x00;
18cb93a386Sopenharmony_ci        }
19cb93a386Sopenharmony_ci    }
20cb93a386Sopenharmony_ci    bitmap.setPixels(pixels);
21cb93a386Sopenharmony_ci    for (auto style : { SkPaint::kFill_Style,
22cb93a386Sopenharmony_ci                        SkPaint::kStroke_Style,
23cb93a386Sopenharmony_ci                        SkPaint::kStrokeAndFill_Style }) {
24cb93a386Sopenharmony_ci        paint.setStyle(style);
25cb93a386Sopenharmony_ci        canvas->drawLine(10, 10, 60, 60, paint);
26cb93a386Sopenharmony_ci        canvas->drawRect({80, 10, 130, 60}, paint);
27cb93a386Sopenharmony_ci        canvas->drawRegion(region, paint);
28cb93a386Sopenharmony_ci        canvas->drawImage(bitmap.asImage(), 200, 10, SkSamplingOptions(), &paint);
29cb93a386Sopenharmony_ci        canvas->translate(0, 80);
30cb93a386Sopenharmony_ci    }
31cb93a386Sopenharmony_ci}
32cb93a386Sopenharmony_ci}  // END FIDDLE
33