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=9bc86efda08cbcd9c6f7c5f220294a24 5cb93a386Sopenharmony_ciREG_FIDDLE(Path_getPoints, 256, 256, true, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci auto debugster = [](const char* prefix, const SkPath& path, SkPoint* points, int max) -> void { 8cb93a386Sopenharmony_ci int count = path.getPoints(points, max); 9cb93a386Sopenharmony_ci SkDebugf("%s point count: %d ", prefix, count); 10cb93a386Sopenharmony_ci for (int i = 0; i < std::min(count, max) && points; ++i) { 11cb93a386Sopenharmony_ci SkDebugf("(%1.8g,%1.8g) ", points[i].fX, points[i].fY); 12cb93a386Sopenharmony_ci } 13cb93a386Sopenharmony_ci SkDebugf("\n"); 14cb93a386Sopenharmony_ci }; 15cb93a386Sopenharmony_ci SkPath path; 16cb93a386Sopenharmony_ci path.lineTo(20, 20); 17cb93a386Sopenharmony_ci path.lineTo(-10, -10); 18cb93a386Sopenharmony_ci SkPoint points[3]; 19cb93a386Sopenharmony_ci debugster("no points", path, nullptr, 0); 20cb93a386Sopenharmony_ci debugster("zero max", path, points, 0); 21cb93a386Sopenharmony_ci debugster("too small", path, points, 2); 22cb93a386Sopenharmony_ci debugster("just right", path, points, path.countPoints()); 23cb93a386Sopenharmony_ci} 24cb93a386Sopenharmony_ci} // END FIDDLE 25