| 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(skcanvas_paint, 256, 256, false, 5) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
canvas->drawColor(SK_ColorWHITE); |
| 7 |
|
| 8 |
SkPaint paint; |
| 9 |
paint.setStyle(SkPaint::kStroke_Style); |
| 10 |
paint.setStrokeWidth(4); |
| 11 |
paint.setColor(SK_ColorRED); |
| 12 |
|
| 13 |
SkRect rect = SkRect::MakeXYWH(50, 50, 40, 60); |
| 14 |
canvas->drawRect(rect, paint); |
| 15 |
|
| 16 |
SkRRect oval; |
| 17 |
oval.setOval(rect); |
| 18 |
oval.offset(40, 60); |
| 19 |
paint.setColor(SK_ColorBLUE); |
| 20 |
canvas->drawRRect(oval, paint); |
| 21 |
|
| 22 |
paint.setColor(SK_ColorCYAN); |
| 23 |
canvas->drawCircle(180, 50, 25, paint); |
| 24 |
|
| 25 |
rect.offset(80, 0); |
| 26 |
paint.setColor(SK_ColorYELLOW); |
| 27 |
canvas->drawRoundRect(rect, 10, 10, paint); |
| 28 |
|
| 29 |
SkPath path = SkPathBuilder().cubicTo(768, 0, -512, 256, 256, 256).detach(); |
| 30 |
paint.setColor(SK_ColorGREEN); |
| 31 |
canvas->drawPath(path, paint); |
| 32 |
|
| 33 |
canvas->drawImage(image, 128, 128, SkSamplingOptions(), &paint); |
| 34 |
|
| 35 |
SkRect rect2 = SkRect::MakeXYWH(0, 0, 40, 60); |
| 36 |
canvas->drawImageRect(image, rect2, SkSamplingOptions(), &paint); |
| 37 |
|
| 38 |
SkPaint paint2; |
| 39 |
auto text = SkTextBlob::MakeFromString("Hello, Skia!", SkFont(nullptr, 18)); |
| 40 |
canvas->drawTextBlob(text.get(), 50, 25, paint2); |
| 41 |
} |
| 42 |
} // END FIDDLE |