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=466445ed991d86de08587066392d654a
5cb93a386Sopenharmony_ciREG_FIDDLE(Cubic, 256, 160, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    SkPaint paint;
8cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
9cb93a386Sopenharmony_ci    paint.setStyle(SkPaint::kStroke_Style);
10cb93a386Sopenharmony_ci    SkPoint cubicPts[] = {{20, 150}, {90, 10}, {160, 150}, {230, 10}};
11cb93a386Sopenharmony_ci    SkColor colors[] = { 0xff88ff00, 0xff0088bb, 0xff6600cc, 0xffbb3377 };
12cb93a386Sopenharmony_ci    for (unsigned i = 0; i < SK_ARRAY_COUNT(colors); ++i) {
13cb93a386Sopenharmony_ci        paint.setColor(0x7fffffff & colors[i]);
14cb93a386Sopenharmony_ci        paint.setStrokeWidth(1);
15cb93a386Sopenharmony_ci        for (unsigned j = 0; j < 3; ++j) {
16cb93a386Sopenharmony_ci            canvas->drawLine(cubicPts[j], cubicPts[j + 1], paint);
17cb93a386Sopenharmony_ci        }
18cb93a386Sopenharmony_ci        SkPath path;
19cb93a386Sopenharmony_ci        path.moveTo(cubicPts[0]);
20cb93a386Sopenharmony_ci        path.cubicTo(cubicPts[1], cubicPts[2], cubicPts[3]);
21cb93a386Sopenharmony_ci        paint.setStrokeWidth(3);
22cb93a386Sopenharmony_ci        paint.setColor(colors[i]);
23cb93a386Sopenharmony_ci        canvas->drawPath(path, paint);
24cb93a386Sopenharmony_ci        cubicPts[1].fY += 30;
25cb93a386Sopenharmony_ci        cubicPts[2].fX += 30;
26cb93a386Sopenharmony_ci   }
27cb93a386Sopenharmony_ci}
28cb93a386Sopenharmony_ci}  // END FIDDLE
29