4 {
5
6
8 const char* sksl =
9
10 "const half3 iColor = half3(0, 0.5, 0.75);"
11 "half4 main(float2 coord) {"
12 " float alpha = 1 - (coord.y / 150);"
13 " if (coord.x < 100) {"
14 " /* Correctly premultiplied version of color */"
15 " return iColor.rgb1 * alpha;"
16 " } else {"
17 " /* Returning an unpremultiplied color (just setting alpha) leads to over-bright colors. */"
18 " return half4(iColor, alpha);"
19 " }"
20 "}";
21
24 {});
25
26
28
29
31 p.setShader(myShader);
33}}
constexpr SkColor SK_ColorGRAY
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void drawPaint(const SkPaint &paint)
static Result MakeForShader(SkString sksl, const Options &)