Flutter Engine
The Flutter Engine
third_party
skia
docs
examples
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.
3
#include "
tools/fiddle/examples.h
"
4
REG_FIDDLE
(skpaint_skia, 256, 256,
false
, 0) {
5
// https://fiddle.skia.org/c/@skpaint_skia
6
7
void
draw
(
SkCanvas
* canvas) {
8
SkPaint
paint1, paint2, paint3;
9
10
paint1.
setAntiAlias
(
true
);
11
paint1.
setColor
(
SkColorSetRGB
(255, 0, 0));
12
paint1.
setStyle
(
SkPaint::kFill_Style
);
13
14
paint2.
setAntiAlias
(
true
);
15
paint2.
setColor
(
SkColorSetRGB
(0, 136, 0));
16
paint2.
setStyle
(
SkPaint::kStroke_Style
);
17
paint2.
setStrokeWidth
(
SkIntToScalar
(3));
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
SkColorSetRGB
#define SkColorSetRGB(r, g, b)
Definition:
SkColor.h:57
SK_ColorWHITE
constexpr SkColor SK_ColorWHITE
Definition:
SkColor.h:122
SkIntToScalar
#define SkIntToScalar(x)
Definition:
SkScalar.h:57
draw
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition:
aaclip.cpp:27
SkCanvas
Definition:
SkCanvas.h:106
SkCanvas::clear
void clear(SkColor color)
Definition:
SkCanvas.h:1199
SkCanvas::drawTextBlob
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition:
SkCanvas.cpp:2484
SkFont
Definition:
SkFont.h:35
SkPaint
Definition:
SkPaint.h:44
SkPaint::setStyle
void setStyle(Style style)
Definition:
SkPaint.cpp:105
SkPaint::setColor
void setColor(SkColor color)
Definition:
SkPaint.cpp:119
SkPaint::setAntiAlias
void setAntiAlias(bool aa)
Definition:
SkPaint.h:170
SkPaint::kStroke_Style
@ kStroke_Style
set to stroke geometry
Definition:
SkPaint.h:194
SkPaint::kFill_Style
@ kFill_Style
set to fill geometry
Definition:
SkPaint.h:193
SkPaint::setStrokeWidth
void setStrokeWidth(SkScalar width)
Definition:
SkPaint.cpp:159
SkTextBlob::MakeFromString
static sk_sp< SkTextBlob > MakeFromString(const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition:
SkTextBlob.h:115
sk_sp< SkTextBlob >
sk_sp::get
T * get() const
Definition:
SkRefCnt.h:303
examples.h
REG_FIDDLE
REG_FIDDLE(skpaint_skia, 256, 256, false, 0)
Definition:
skpaint_skia.cpp:4
Generated on Sun Jun 23 2024 21:55:56 for Flutter Engine by
1.9.4