Flutter Engine
The Flutter Engine
Functions
shader_alphaimage.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (shader_alphaimage, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( shader_alphaimage  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file shader_alphaimage.cpp.

4 {
5sk_sp<SkImage> alpha_image() {
7 s->getCanvas()->clear(SkColorSetARGB(0xF0, 0x00, 0x00, 0x00));
8 return s->makeImageSnapshot();
9}
10sk_sp<SkShader> linear_gradient() {
11 SkPoint gpts[2] = {{0, 0}, {256, 256}};
14 return SkGradientShader::MakeLinear(gpts, gc, nullptr, 6, SkTileMode::kClamp);
15}
16
17void draw(SkCanvas* canvas) {
18 canvas->clear(SK_ColorLTGRAY);
19 SkPaint p;
20 p.setShader(linear_gradient());
21 auto i = alpha_image();
22 canvas->drawImage(i.get(), 128, 0, SkSamplingOptions(), &p);
23 canvas->drawRect({0, 128, 128, 256}, p);
24}
25} // END FIDDLE
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
constexpr SkColor SK_ColorLTGRAY
Definition: SkColor.h:118
constexpr SkColor SK_ColorMAGENTA
Definition: SkColor.h:147
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorCYAN
Definition: SkColor.h:143
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
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 clear(SkColor color)
Definition: SkCanvas.h:1199
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
struct MyStruct s
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial gc
Definition: switches.h:238
static SkImageInfo MakeA8(int width, int height)