1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC. 2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h" 4cb93a386Sopenharmony_ci// HASH=1955856d45773a4fd914fcc1f813222f 5cb93a386Sopenharmony_ciREG_FIDDLE(Dst_Atop, 256, 256, false, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; 8cb93a386Sopenharmony_ci SkPoint horz[] = { { 0, 0 }, { 256, 0 } }; 9cb93a386Sopenharmony_ci SkPaint paint; 10cb93a386Sopenharmony_ci paint.setShader(SkGradientShader::MakeLinear(horz, colors, nullptr, SK_ARRAY_COUNT(colors), 11cb93a386Sopenharmony_ci SkTileMode::kClamp)); 12cb93a386Sopenharmony_ci canvas->drawPaint(paint); 13cb93a386Sopenharmony_ci paint.setBlendMode(SkBlendMode::kDstATop); 14cb93a386Sopenharmony_ci SkColor alphas[] = { SK_ColorBLACK, SK_ColorTRANSPARENT }; 15cb93a386Sopenharmony_ci SkPoint vert[] = { { 0, 0 }, { 0, 256 } }; 16cb93a386Sopenharmony_ci paint.setShader(SkGradientShader::MakeLinear(vert, alphas, nullptr, SK_ARRAY_COUNT(alphas), 17cb93a386Sopenharmony_ci SkTileMode::kClamp)); 18cb93a386Sopenharmony_ci canvas->drawPaint(paint); 19cb93a386Sopenharmony_ci canvas->clipRect( { 30, 30, 226, 226 } ); 20cb93a386Sopenharmony_ci canvas->drawColor(SkColorSetA(SK_ColorGREEN, 128), SkBlendMode::kSrcATop); 21cb93a386Sopenharmony_ci} 22cb93a386Sopenharmony_ci} // END FIDDLE 23