b339d051e0
Bug: skia:7650 Change-Id: I0fa4c5f3fb350705f78ee91f4bdfb4edd83d0ed9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361360 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
// Copyright 2020 Google LLC.
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
#include "tools/fiddle/examples.h"
|
|
REG_FIDDLE(skcanvas_paint, 256, 256, false, 5) {
|
|
void draw(SkCanvas* canvas) {
|
|
canvas->drawColor(SK_ColorWHITE);
|
|
|
|
SkPaint paint;
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
paint.setStrokeWidth(4);
|
|
paint.setColor(SK_ColorRED);
|
|
|
|
SkRect rect = SkRect::MakeXYWH(50, 50, 40, 60);
|
|
canvas->drawRect(rect, paint);
|
|
|
|
SkRRect oval;
|
|
oval.setOval(rect);
|
|
oval.offset(40, 60);
|
|
paint.setColor(SK_ColorBLUE);
|
|
canvas->drawRRect(oval, paint);
|
|
|
|
paint.setColor(SK_ColorCYAN);
|
|
canvas->drawCircle(180, 50, 25, paint);
|
|
|
|
rect.offset(80, 0);
|
|
paint.setColor(SK_ColorYELLOW);
|
|
canvas->drawRoundRect(rect, 10, 10, paint);
|
|
|
|
SkPath path;
|
|
path.cubicTo(768, 0, -512, 256, 256, 256);
|
|
paint.setColor(SK_ColorGREEN);
|
|
canvas->drawPath(path, paint);
|
|
|
|
canvas->drawImage(image, 128, 128, SkSamplingOptions(), &paint);
|
|
|
|
SkRect rect2 = SkRect::MakeXYWH(0, 0, 40, 60);
|
|
canvas->drawImageRect(image, rect2, SkSamplingOptions(), &paint);
|
|
|
|
SkPaint paint2;
|
|
auto text = SkTextBlob::MakeFromString("Hello, Skia!", SkFont(nullptr, 18));
|
|
canvas->drawTextBlob(text.get(), 50, 25, paint2);
|
|
}
|
|
} // END FIDDLE
|