2020-01-10 20:22:09 +00:00
|
|
|
// 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);
|
|
|
|
|
2021-01-28 16:20:41 +00:00
|
|
|
canvas->drawImage(image, 128, 128, SkSamplingOptions(), &paint);
|
2020-01-10 20:22:09 +00:00
|
|
|
|
|
|
|
SkRect rect2 = SkRect::MakeXYWH(0, 0, 40, 60);
|
2021-01-28 16:20:41 +00:00
|
|
|
canvas->drawImageRect(image, rect2, SkSamplingOptions(), &paint);
|
2020-01-10 20:22:09 +00:00
|
|
|
|
|
|
|
SkPaint paint2;
|
|
|
|
auto text = SkTextBlob::MakeFromString("Hello, Skia!", SkFont(nullptr, 18));
|
|
|
|
canvas->drawTextBlob(text.get(), 50, 25, paint2);
|
|
|
|
}
|
|
|
|
} // END FIDDLE
|