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=871b0da9b4a23de11ae7a772ce14aed3 5cb93a386Sopenharmony_ciREG_FIDDLE(Canvas_drawRect, 256, 256, false, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci SkPoint rectPts[] = { {64, 48}, {192, 160} }; 8cb93a386Sopenharmony_ci SkPaint paint; 9cb93a386Sopenharmony_ci paint.setAntiAlias(true); 10cb93a386Sopenharmony_ci paint.setStyle(SkPaint::kStroke_Style); 11cb93a386Sopenharmony_ci paint.setStrokeWidth(20); 12cb93a386Sopenharmony_ci paint.setStrokeJoin(SkPaint::kRound_Join); 13cb93a386Sopenharmony_ci SkMatrix rotator; 14cb93a386Sopenharmony_ci rotator.setRotate(30, 128, 128); 15cb93a386Sopenharmony_ci for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorMAGENTA } ) { 16cb93a386Sopenharmony_ci paint.setColor(color); 17cb93a386Sopenharmony_ci SkRect rect; 18cb93a386Sopenharmony_ci rect.set(rectPts[0], rectPts[1]); 19cb93a386Sopenharmony_ci canvas->drawRect(rect, paint); 20cb93a386Sopenharmony_ci rotator.mapPoints(rectPts, 2); 21cb93a386Sopenharmony_ci } 22cb93a386Sopenharmony_ci} 23cb93a386Sopenharmony_ci} // END FIDDLE 24