Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
gradtext.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include "tools/ToolUtils.h"
#include "tools/fonts/FontToolUtils.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (gradtext, canvas, 500, 480)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( gradtext  ,
canvas  ,
500  ,
480   
)

Definition at line 106 of file gradtext.cpp.

106 {
107 static constexpr float kTextSize = 26.0f;
109
110 canvas->drawRect({0, 0, 500, 240}, SkPaint());
111 canvas->translate(20.0f, kTextSize);
112
113 SkPaint paints[2];
114 paints[0].setShader(make_grad(80.0f));
115 paints[1].setShader(make_grad2(80.0f));
116
117 static const SkFont::Edging edgings[3] = {
121 };
122 for (int i = 0; i < 2; ++i) {
123 for (const SkPaint& paint : paints) {
124 for (SkFont::Edging edging : edgings) {
125 font.setEdging(edging);
126 canvas->drawString("When in the course of human events", 0, 0, font, paint);
127 canvas->translate(0, kTextSize * 4/3);
128 }
129 canvas->translate(0, kTextSize * 2/3);
130 }
131 }
132}
Edging
Definition SkFont.h:39
@ kAntiAlias
may have transparent pixels on glyph edges
@ kAlias
no transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
void setShader(sk_sp< SkShader > shader)
const Paint & paint
static sk_sp< SkShader > make_grad(SkScalar width)
Definition hsl.cpp:202
sk_sp< SkTypeface > DefaultPortableTypeface()
font
Font Metadata and Metrics.