| // 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, &paint); |
| |
| SkRect rect2 = SkRect::MakeXYWH(0, 0, 40, 60); |
| canvas->drawImageRect(image, rect2, &paint); |
| |
| SkPaint paint2; |
| auto text = SkTextBlob::MakeFromString("Hello, Skia!", SkFont(nullptr, 18)); |
| canvas->drawTextBlob(text.get(), 50, 25, paint2); |
| } |
| } // END FIDDLE |