Flutter Engine
The Flutter Engine
skpaint_mix.cpp
Go to the documentation of this file.
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.
4REG_FIDDLE(skpaint_mix, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkPaint fillPaint;
7 SkPaint strokePaint;
9 strokePaint.setStrokeWidth(3.0f);
10
11 canvas->drawRect(SkRect::MakeXYWH(10, 10, 60, 20), fillPaint);
12 canvas->drawRect(SkRect::MakeXYWH(80, 10, 60, 20), strokePaint);
13
14 strokePaint.setStrokeWidth(5.0f);
15 canvas->drawOval(SkRect::MakeXYWH(150, 10, 60, 20), strokePaint);
16
17 sk_sp<SkTextBlob> blob = SkTextBlob::MakeFromString("SKIA", SkFont(nullptr, 80));
18
19 fillPaint.setColor(SkColorSetARGB(0xFF, 0xFF, 0x00, 0x00));
20 canvas->drawTextBlob(blob.get(), 20, 120, fillPaint);
21
22 fillPaint.setColor(SkColorSetARGB(0xFF, 0x00, 0x00, 0xFF));
23 canvas->drawTextBlob(blob.get(), 20, 220, fillPaint);
24}
25} // END FIDDLE
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
Definition: SkFont.h:35
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition: SkTextBlob.h:115
T * get() const
Definition: SkRefCnt.h:303
REG_FIDDLE(skpaint_mix, 256, 256, false, 0)
Definition: skpaint_mix.cpp:4
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659