Flutter Engine
The Flutter Engine
skpaint_skia.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_skia, 256, 256, false, 0) {
5// https://fiddle.skia.org/c/@skpaint_skia
6
7void draw(SkCanvas* canvas) {
8 SkPaint paint1, paint2, paint3;
9
10 paint1.setAntiAlias(true);
11 paint1.setColor(SkColorSetRGB(255, 0, 0));
13
14 paint2.setAntiAlias(true);
15 paint2.setColor(SkColorSetRGB(0, 136, 0));
18
19 paint3.setAntiAlias(true);
20 paint3.setColor(SkColorSetRGB(136, 136, 136));
21
22 sk_sp<SkTextBlob> blob1 =
23 SkTextBlob::MakeFromString("Skia!", SkFont(nullptr, 64.0f, 1.0f, 0.0f));
24 sk_sp<SkTextBlob> blob2 =
25 SkTextBlob::MakeFromString("Skia!", SkFont(nullptr, 64.0f, 1.5f, 0.0f));
26
27 canvas->clear(SK_ColorWHITE);
28 canvas->drawTextBlob(blob1.get(), 20.0f, 64.0f, paint1);
29 canvas->drawTextBlob(blob1.get(), 20.0f, 144.0f, paint2);
30 canvas->drawTextBlob(blob2.get(), 20.0f, 224.0f, paint3);
31}
32} // END FIDDLE
#define SkColorSetRGB(r, g, b)
Definition: SkColor.h:57
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void clear(SkColor color)
Definition: SkCanvas.h:1199
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
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
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_skia, 256, 256, false, 0)
Definition: skpaint_skia.cpp:4