25 float angleStep = 360.0f / n, angle = 0.0f;
27 angle = angleStep/2.0f;
30 for (
int i = 0; i < n; ++i) {
109 { -47.55f, -15.45f },
110 { -40.45f, -29.39f },
111 { -29.39f, -40.45f },
112 { -15.45f, -47.55f },
126 { -72.55f, -15.45f },
127 { -65.45f, -29.39f },
128 { -54.39f, -40.45f },
129 { -40.45f, -47.55f },
163static_assert(std::size(
gSizes) == std::size(
gPoints),
"array_mismatch");
178 if (fDoStrokeAndFill) {
179 return SkString(
"convex-lineonly-paths-stroke-and-fill");
181 return SkString(
"convex-lineonly-paths");
187 std::unique_ptr<SkPoint[]> data(
nullptr);
210 width = kMaxPathHeight/5;
220 width = kMaxPathHeight/5;
233 data = std::make_unique<SkPoint[]>(numPts);
242 builder.moveTo(
points[0]);
243 for (
int i = 1; i < numPts; ++i) {
244 builder.lineTo(
points[i]);
247 builder.moveTo(
points[numPts-1]);
248 for (
int i = numPts-2; i >= 0; --i) {
249 builder.lineTo(
points[i]);
254 SkPath path = builder.detach();
263 SkRect bounds = path.getBounds();
265 SkASSERT(bounds.height() <= kMaxPathHeight);
277 if (
offset->fX+path.getBounds().width() > kGMWidth) {
279 offset->fY += kMaxPathHeight;
280 if (fDoStrokeAndFill) {
281 offset->fX += kStrokeWidth / 2.0f;
282 offset->fY += kStrokeWidth / 2.0f;
286 offset->fX += path.getBounds().width();
287 if (fDoStrokeAndFill) {
288 offset->fX += kStrokeWidth;
294 const float scales[] = { 1.0f, 0.75f, 0.5f, 0.25f, 0.1f, 0.01f, 0.001f };
300 paint.setAntiAlias(
true);
302 for (
size_t i = 0; i < std::size(scales); ++i) {
304 if (fDoStrokeAndFill) {
306 paint.setStrokeJoin(joins[i%3]);
312 canvas->
scale(scales[i], scales[i]);
313 paint.setColor(colors[i%2]);
322 if (fDoStrokeAndFill) {
324 offset.fY += kStrokeWidth / 2.0f;
327 for (
int i = 0; i < kNumPaths; ++i) {
335 p.setAntiAlias(
true);
336 if (fDoStrokeAndFill) {
343 {60.8522949f, 364.671021f},
344 {59.4380493f, 364.671021f},
345 {385.414276f, 690.647217f},
346 {386.121399f, 689.940125f},
378 {1184.96f, 982.557f},
379 {1183.71f, 982.865f},
380 {1180.99f, 982.734f},
382 {1176.35f, 979.367f},
383 {1178.94f, 938.854f},
384 {1181.35f, 936.038f},
385 {1183.96f, 934.117f},
386 {1186.67f, 933.195f},
387 {1189.36f, 933.342f},
392 m.setAll(0.0893210843f, 0, 79.1197586f, 0, 0.0893210843f, 300, 0, 0, 1);
400 inline static constexpr int kStrokeWidth = 10;
401 inline static constexpr int kNumPaths = 20;
402 inline static constexpr int kMaxPathHeight = 100;
403 inline static constexpr int kGMWidth = 512;
404 inline static constexpr int kGMHeight = 512;
406 bool fDoStrokeAndFill;
408 using INHERITED =
GM;
413DEF_GM(
return new ConvexLineOnlyPathsGM(
false);)
414DEF_GM(
return new ConvexLineOnlyPathsGM(
true);)
static const int points[]
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
#define SkDegreesToRadians(degrees)
#define SkScalarSin(radians)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
#define SkScalarCos(radians)
static SkScalar center(float pos0, float pos1)
Type::kYUV Type::kRGBA() int(0.7 *637)
void translate(SkScalar dx, SkScalar dy)
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
void concat(const SkMatrix &matrix)
@ kStrokeAndFill_Style
sets to stroke and fill geometry
@ kMiter_Join
extends to miter limit
@ kBevel_Join
connects outside edges
static SkPathFirstDirection AsFirstDirection(SkPathDirection dir)
static SkPathFirstDirection ComputeFirstDirection(const SkPath &)
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
SkISize getISize() override
bool runAsBench() const override
static SkPath GetPath(int index, SkPathDirection dir)
void drawPath(SkCanvas *canvas, int index, SkPoint *offset)
void onDraw(SkCanvas *canvas) override
ConvexLineOnlyPathsGM(bool doStrokeAndFill)
SkString getName() const override
static void create_ngon(int n, SkPoint *pts, SkScalar width, SkScalar height)
const SkPoint * gPoints[]
const SkPoint gPoints10[]
static constexpr SkISize Make(int32_t w, int32_t h)