aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/polygonoffset.cpp
blob: 44a313b28570595e82ea092ed97ef15a34fc26fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/*
 * Copyright 2018 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"
#include "sk_tool_utils.h"
#include "SkPolyUtils.h"
#include "SkPathPriv.h"

static void create_ngon(int n, SkPoint* pts, SkScalar w, SkScalar h, SkPath::Direction dir) {
    float angleStep = 360.0f / n, angle = 0.0f, sin, cos;
    if ((n % 2) == 1) {
        angle = angleStep/2.0f;
    }
    if (SkPath::kCCW_Direction == dir) {
        angle = -angle;
        angleStep = -angleStep;
    }

    for (int i = 0; i < n; ++i) {
        sin = SkScalarSinCos(SkDegreesToRadians(angle), &cos);
        pts[i].fX = -sin * w;
        pts[i].fY = cos * h;
        angle += angleStep;
    }
}

namespace PolygonOffsetData {
// narrow rect
const SkPoint gPoints0[] = {
    { -1.5f, -50.0f },
    { 1.5f, -50.0f },
    { 1.5f,  50.0f },
    { -1.5f,  50.0f }
};
// narrow rect on an angle
const SkPoint gPoints1[] = {
    { -50.0f, -49.0f },
    { -49.0f, -50.0f },
    { 50.0f,  49.0f },
    { 49.0f,  50.0f }
};
// trap - narrow on top - wide on bottom
const SkPoint gPoints2[] = {
    { -10.0f, -50.0f },
    { 10.0f, -50.0f },
    { 50.0f,  50.0f },
    { -50.0f,  50.0f }
};
// wide skewed rect
const SkPoint gPoints3[] = {
    { -50.0f, -50.0f },
    { 0.0f, -50.0f },
    { 50.0f,  50.0f },
    { 0.0f,  50.0f }
};
// thin rect with colinear-ish lines
const SkPoint gPoints4[] = {
    { -6.0f, -50.0f },
    { 4.0f, -50.0f },
    { 5.0f, -25.0f },
    { 6.0f,   0.0f },
    { 5.0f,  25.0f },
    { 4.0f,  50.0f },
    { -4.0f,  50.0f }
};
// degenerate
const SkPoint gPoints5[] = {
    { -0.025f, -0.025f },
    { 0.025f, -0.025f },
    { 0.025f,  0.025f },
    { -0.025f,  0.025f }
};
// Quad with near coincident point
const SkPoint gPoints6[] = {
    { -20.0f, -13.0f },
    { -20.0f, -13.05f },
    { 20.0f, -13.0f },
    { 20.0f,  27.0f }
};
// thin rect with colinear lines
const SkPoint gPoints7[] = {
    { -10.0f, -50.0f },
    { 10.0f, -50.0f },
    { 10.0f, -25.0f },
    { 10.0f,   0.0f },
    { 10.0f,  25.0f },
    { 10.0f,  50.0f },
    { -10.0f,  50.0f }
};
// capped teardrop
const SkPoint gPoints8[] = {
    { 50.00f,  50.00f },
    { 0.00f,  50.00f },
    { -15.45f,  47.55f },
    { -29.39f,  40.45f },
    { -40.45f,  29.39f },
    { -47.55f,  15.45f },
    { -50.00f,   0.00f },
    { -47.55f, -15.45f },
    { -40.45f, -29.39f },
    { -29.39f, -40.45f },
    { -15.45f, -47.55f },
    { 0.00f, -50.00f },
    { 50.00f, -50.00f }
};
// teardrop
const SkPoint gPoints9[] = {
    { 4.39f,  40.45f },
    { -9.55f,  47.55f },
    { -25.00f,  50.00f },
    { -40.45f,  47.55f },
    { -54.39f,  40.45f },
    { -65.45f,  29.39f },
    { -72.55f,  15.45f },
    { -75.00f,   0.00f },
    { -72.55f, -15.45f },
    { -65.45f, -29.39f },
    { -54.39f, -40.45f },
    { -40.45f, -47.55f },
    { -25.0f,  -50.0f },
    { -9.55f, -47.55f },
    { 4.39f, -40.45f },
    { 75.00f,   0.00f }
};
// clipped triangle
const SkPoint gPoints10[] = {
    { -10.0f, -50.0f },
    { 10.0f, -50.0f },
    { 50.0f,  31.0f },
    { 40.0f,  50.0f },
    { -40.0f,  50.0f },
    { -50.0f,  31.0f },
};

// tab
const SkPoint gPoints11[] = {
    { -45, -25 },
    { 45, -25 },
    { 45, 25 },
    { 20, 25 },
    { 19.6157f, 25.f + 3.9018f },
    { 18.4776f, 25.f + 7.6537f },
    { 16.6294f, 25.f + 11.1114f },
    { 14.1421f, 25.f + 14.1421f },
    { 11.1114f, 25.f + 16.6294f },
    { 7.6537f, 25.f + 18.4776f },
    { 3.9018f, 25.f + 19.6157f },
    { 0, 45.f },
    { -3.9018f, 25.f + 19.6157f },
    { -7.6537f, 25.f + 18.4776f },
    { -11.1114f, 25.f + 16.6294f },
    { -14.1421f, 25.f + 14.1421f },
    { -16.6294f, 25.f + 11.1114f },
    { -18.4776f, 25.f + 7.6537f },
    { -19.6157f, 25.f + 3.9018f },
    { -20, 25 },
    { -45, 25 }
};

// star of david
const SkPoint gPoints12[] = {
    { 0.0f, -50.0f },
    { 14.43f, -25.0f },
    { 43.30f, -25.0f },
    { 28.86f, 0.0f },
    { 43.30f, 25.0f },
    { 14.43f, 25.0f },
    { 0.0f, 50.0f },
    { -14.43f, 25.0f },
    { -43.30f, 25.0f },
    { -28.86f, 0.0f },
    { -43.30f, -25.0f },
    { -14.43f, -25.0f },
};

// notch
const SkScalar kBottom = 25.f;
const SkPoint gPoints13[] = {
    { -50, kBottom - 50.f },
    { 50, kBottom - 50.f },
    { 50, kBottom },
    { 20, kBottom },
    { 19.6157f, kBottom - 3.9018f },
    { 18.4776f, kBottom - 7.6537f },
    { 16.6294f, kBottom - 11.1114f },
    { 14.1421f, kBottom - 14.1421f },
    { 11.1114f, kBottom - 16.6294f },
    { 7.6537f, kBottom - 18.4776f },
    { 3.9018f, kBottom - 19.6157f },
    { 0, kBottom - 20.f },
    { -3.9018f, kBottom - 19.6157f },
    { -7.6537f, kBottom - 18.4776f },
    { -11.1114f, kBottom - 16.6294f },
    { -14.1421f, kBottom - 14.1421f },
    { -16.6294f, kBottom - 11.1114f },
    { -18.4776f, kBottom - 7.6537f },
    { -19.6157f, kBottom - 3.9018f },
    { -20, kBottom },
    { -50, kBottom }
};

// crown
const SkPoint gPoints14[] = {
    { -40, -39 },
    { 40, -39 },
    { 40, -20 },
    { 30, 40 },
    { 20, -20 },
    { 10, 40 },
    { 0, -20 },
    { -10, 40 },
    { -20, -20 },
    { -30, 40 },
    { -40, -20 }
};

// dumbbell
const SkPoint gPoints15[] = {
    { -26, -3 },
    { -24, -6.2f },
    { -22.5f, -8 },
    { -20, -9.9f },
    { -17.5f, -10.3f },
    { -15, -10.9f },
    { -12.5f, -10.2f },
    { -10, -9.7f },
    { -7.5f, -8.1f },
    { -5, -7.7f },
    { -2.5f, -7.4f },
    { 0, -7.7f },
    { 3, -9 },
    { 6.5f, -11.5f },
    { 10.6f, -14 },
    { 14, -15.2f },
    { 17, -15.5f },
    { 20, -15.2f },
    { 23.4f, -14 },
    { 27.5f, -11.5f },
    { 30, -8 },
    { 32, -4 },
    { 32.5f, 0 },
    { 32, 4 },
    { 30, 8 },
    { 27.5f, 11.5f },
    { 23.4f, 14 },
    { 20, 15.2f },
    { 17, 15.5f },
    { 14, 15.2f },
    { 10.6f, 14 },
    { 6.5f, 11.5f },
    { 3, 9 },
    { 0, 7.7f },
    { -2.5f, 7.4f },
    { -5, 7.7f },
    { -7.5f, 8.1f },
    { -10, 9.7f },
    { -12.5f, 10.2f },
    { -15, 10.9f },
    { -17.5f, 10.3f },
    { -20, 9.9f },
    { -22.5f, 8 },
    { -24, 6.2f },
    { -26, 3 },
    { -26.5f, 0 }
};

// truncated dumbbell
// (checks winding computation in OffsetSimplePolygon)
const SkPoint gPoints16[] = {
    { -15 + 3, -9 },
    { -15 + 6.5f, -11.5f },
    { -15 + 10.6f, -14 },
    { -15 + 14, -15.2f },
    { -15 + 17, -15.5f },
    { -15 + 20, -15.2f },
    { -15 + 23.4f, -14 },
    { -15 + 27.5f, -11.5f },
    { -15 + 30, -8 },
    { -15 + 32, -4 },
    { -15 + 32.5f, 0 },
    { -15 + 32, 4 },
    { -15 + 30, 8 },
    { -15 + 27.5f, 11.5f },
    { -15 + 23.4f, 14 },
    { -15 + 20, 15.2f },
    { -15 + 17, 15.5f },
    { -15 + 14, 15.2f },
    { -15 + 10.6f, 14 },
    { -15 + 6.5f, 11.5f },
    { -15 + 3, 9 },
};

// square notch
// (to detect segment-segment intersection)
const SkPoint gPoints17[] = {
    { -50, kBottom - 50.f },
    { 50, kBottom - 50.f },
    { 50, kBottom },
    { 20, kBottom },
    { 20, kBottom - 20.f },
    { -20, kBottom - 20.f },
    { -20, kBottom },
    { -50, kBottom }
};

// box with Peano curve
const SkPoint gPoints18[] = {
    { 0, 0 },
    { 0, -12 },
    { -6, -12 },
    { -6, 0 },
    { -12, 0 },
    { -12, -12},
    { -18, -12},
    { -18, 18},
    { -12, 18},
    {-12, 6},
    {-6, 6},
    {-6, 36},
    {-12, 36},
    {-12, 24},
    {-18, 24},
    {-18, 36},
    {-24, 36},
    {-24, 24},
    {-30, 24},
    {-30, 36},
    {-36, 36},
    {-36, 6},
    {-30, 6},
    {-30, 18},
    {-24, 18},
    {-24, -12},
    {-30, -12},
    {-30, 0},
    {-36, 0},
    {-36, -36},
    {36, -36},
    {36, 36},
    {12, 36},
    {12, 24},
    {6, 24},
    {6, 36},
    {0, 36},
    {0, 6},
    {6, 6},
    {6, 18},
    {12, 18},
    {12, -12},
    {6, -12},
    {6, 0}
};


const SkPoint* gConvexPoints[] = {
    gPoints0, gPoints1, gPoints2, gPoints3, gPoints4, gPoints5, gPoints6,
    gPoints7, gPoints8, gPoints9, gPoints10,
};

const size_t gConvexSizes[] = {
    SK_ARRAY_COUNT(gPoints0),
    SK_ARRAY_COUNT(gPoints1),
    SK_ARRAY_COUNT(gPoints2),
    SK_ARRAY_COUNT(gPoints3),
    SK_ARRAY_COUNT(gPoints4),
    SK_ARRAY_COUNT(gPoints5),
    SK_ARRAY_COUNT(gPoints6),
    SK_ARRAY_COUNT(gPoints7),
    SK_ARRAY_COUNT(gPoints8),
    SK_ARRAY_COUNT(gPoints9),
    SK_ARRAY_COUNT(gPoints10),
};
static_assert(SK_ARRAY_COUNT(gConvexSizes) == SK_ARRAY_COUNT(gConvexPoints), "array_mismatch");

const SkPoint* gSimplePoints[] = {
    gPoints0, gPoints1, gPoints2, gPoints4, gPoints5, gPoints7,
    gPoints8, gPoints11, gPoints12, gPoints13, gPoints14, gPoints15,
    gPoints16, gPoints17, gPoints18,
};

const size_t gSimpleSizes[] = {
    SK_ARRAY_COUNT(gPoints0),
    SK_ARRAY_COUNT(gPoints1),
    SK_ARRAY_COUNT(gPoints2),
    SK_ARRAY_COUNT(gPoints4),
    SK_ARRAY_COUNT(gPoints5),
    SK_ARRAY_COUNT(gPoints7),
    SK_ARRAY_COUNT(gPoints8),
    SK_ARRAY_COUNT(gPoints11),
    SK_ARRAY_COUNT(gPoints12),
    SK_ARRAY_COUNT(gPoints13),
    SK_ARRAY_COUNT(gPoints14),
    SK_ARRAY_COUNT(gPoints15),
    SK_ARRAY_COUNT(gPoints16),
    SK_ARRAY_COUNT(gPoints17),
    SK_ARRAY_COUNT(gPoints18),
};
static_assert(SK_ARRAY_COUNT(gSimpleSizes) == SK_ARRAY_COUNT(gSimplePoints), "array_mismatch");

}

namespace skiagm {

// This GM is intended to exercise the offsetting of polygons
// When fVariableOffset is true it will skew the offset by x,
// to test perspective and other variable offset functions
class PolygonOffsetGM : public GM {
public:
    PolygonOffsetGM(bool convexOnly, bool variableOffset)
        : fConvexOnly(convexOnly)
        , fVariableOffset(variableOffset) {
        this->setBGColor(0xFFFFFFFF);
    }

protected:
    SkString onShortName() override {
        if (fConvexOnly) {
            if (fVariableOffset) {
                return SkString("convex-polygon-inset-v");
            } else {
                return SkString("convex-polygon-inset");
            }
        } else {
            if (fVariableOffset) {
                return SkString("simple-polygon-offset-v");
            } else {
                return SkString("simple-polygon-offset");
            }
        }
    }
    SkISize onISize() override { return SkISize::Make(kGMWidth, kGMHeight); }
    bool runAsBench() const override { return true; }

    static void GetConvexPolygon(int index, SkPath::Direction dir,
                                 std::unique_ptr<SkPoint[]>* data, int* numPts) {
        if (index < (int)SK_ARRAY_COUNT(PolygonOffsetData::gConvexPoints)) {
            // manually specified
            *numPts = (int)PolygonOffsetData::gConvexSizes[index];
            data->reset(new SkPoint[*numPts]);
            if (SkPath::kCW_Direction == dir) {
                for (int i = 0; i < *numPts; ++i) {
                    (*data)[i] = PolygonOffsetData::gConvexPoints[index][i];
                }
            } else {
                for (int i = 0; i < *numPts; ++i) {
                    (*data)[i] = PolygonOffsetData::gConvexPoints[index][*numPts - i - 1];
                }
            }
        } else {
            // procedurally generated
            SkScalar width = kMaxPathHeight / 2;
            SkScalar height = kMaxPathHeight / 2;
            int numPtsArray[] = { 3, 4, 5, 5, 6, 8, 8, 20, 100 };

            size_t arrayIndex = index - SK_ARRAY_COUNT(PolygonOffsetData::gConvexPoints);
            SkASSERT(arrayIndex < SK_ARRAY_COUNT(numPtsArray));
            *numPts = numPtsArray[arrayIndex];
            if (arrayIndex == 3 || arrayIndex == 6) {
                // squashed pentagon and octagon
                width = kMaxPathHeight / 5;
            }

            data->reset(new SkPoint[*numPts]);

            create_ngon(*numPts, data->get(), width, height, dir);
        }
    }

    static void GetSimplePolygon(int index, SkPath::Direction dir,
                                 std::unique_ptr<SkPoint[]>* data, int* numPts) {
        if (index < (int)SK_ARRAY_COUNT(PolygonOffsetData::gSimplePoints)) {
            // manually specified
            *numPts = (int)PolygonOffsetData::gSimpleSizes[index];
            data->reset(new SkPoint[*numPts]);
            if (SkPath::kCW_Direction == dir) {
                for (int i = 0; i < *numPts; ++i) {
                    (*data)[i] = PolygonOffsetData::gSimplePoints[index][i];
                }
            } else {
                for (int i = 0; i < *numPts; ++i) {
                    (*data)[i] = PolygonOffsetData::gSimplePoints[index][*numPts - i - 1];
                }
            }
        } else {
            // procedurally generated
            SkScalar width = kMaxPathHeight / 2;
            SkScalar height = kMaxPathHeight / 2;
            int numPtsArray[] = { 5, 7, 8, 20, 100 };

            size_t arrayIndex = index - SK_ARRAY_COUNT(PolygonOffsetData::gSimplePoints);
            arrayIndex = SkTMin(arrayIndex, SK_ARRAY_COUNT(numPtsArray) - 1);
            SkASSERT(arrayIndex < SK_ARRAY_COUNT(numPtsArray));
            *numPts = numPtsArray[arrayIndex];
            // squash horizontally
            width = kMaxPathHeight / 5;

            data->reset(new SkPoint[*numPts]);

            create_ngon(*numPts, data->get(), width, height, dir);
        }
    }
    // Draw a single polygon with insets and potentially outsets
    void drawPolygon(SkCanvas* canvas, int index, SkPoint* offset) {

        SkPoint center;
        SkRect bounds;
        {
            std::unique_ptr<SkPoint[]> data(nullptr);
            int numPts;
            if (fConvexOnly) {
                GetConvexPolygon(index, SkPath::kCW_Direction, &data, &numPts);
            } else {
                GetSimplePolygon(index, SkPath::kCW_Direction, &data, &numPts);
            }
            bounds.set(data.get(), numPts);
            if (!fConvexOnly) {
                bounds.outset(kMaxOutset, kMaxOutset);
            }
            if (offset->fX + bounds.width() > kGMWidth) {
                offset->fX = 0;
                offset->fY += kMaxPathHeight;
            }
            center = { offset->fX + SkScalarHalf(bounds.width()), offset->fY };
            offset->fX += bounds.width();
        }

        const SkPath::Direction dirs[2] = { SkPath::kCW_Direction, SkPath::kCCW_Direction };
        const float insets[] = { 5, 10, 15, 20, 25, 30, 35, 40 };
        const float offsets[] = { 2, 5, 9, 14, 20, 27, 35, 44, -2, -5, -9 };
        const SkColor colors[] = { 0xFF901313, 0xFF8D6214, 0xFF698B14, 0xFF1C8914,
                                   0xFF148755, 0xFF146C84, 0xFF142482, 0xFF4A1480,
                                   0xFF901313, 0xFF8D6214, 0xFF698B14 };

        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setStyle(SkPaint::kStroke_Style);
        paint.setStrokeWidth(1);

        std::unique_ptr<SkPoint[]> data(nullptr);
        int numPts;
        if (fConvexOnly) {
            GetConvexPolygon(index, dirs[index % 2], &data, &numPts);
        } else {
            GetSimplePolygon(index, dirs[index % 2], &data, &numPts);
        }

        {
            SkPath path;
            path.moveTo(data.get()[0]);
            for (int i = 1; i < numPts; ++i) {
                path.lineTo(data.get()[i]);
            }
            path.close();
            canvas->save();
            canvas->translate(center.fX, center.fY);
            canvas->drawPath(path, paint);
            canvas->restore();
        }

        SkTDArray<SkPoint> offsetPoly;
        size_t count = fConvexOnly ? SK_ARRAY_COUNT(insets) : SK_ARRAY_COUNT(offsets);
        SkScalar localCenterX = bounds.centerX();
        for (size_t i = 0; i < count; ++i) {
            SkScalar offset = fConvexOnly ? insets[i] : offsets[i];
            std::function<SkScalar(const SkPoint&)> offsetFunc;
            if (fVariableOffset) {
                offsetFunc = [offset, localCenterX](const SkPoint& p) {
                    return offset + 0.04f*(p.fX - localCenterX);
                };
            } else {
                offsetFunc = [offset](const SkPoint& p) {
                    return offset;
                };
            }

            bool result;
            if (fConvexOnly) {
                result = SkInsetConvexPolygon(data.get(), numPts, offsetFunc, &offsetPoly);
            } else {
                result = SkOffsetSimplePolygon(data.get(), numPts, offsetFunc, &offsetPoly);
            }
            if (result) {
                SkPath path;
                path.moveTo(offsetPoly[0]);
                for (int i = 1; i < offsetPoly.count(); ++i) {
                    path.lineTo(offsetPoly[i]);
                }
                path.close();

                paint.setColor(sk_tool_utils::color_to_565(colors[i]));
                canvas->save();
                canvas->translate(center.fX, center.fY);
                canvas->drawPath(path, paint);
                canvas->restore();
            }
        }
    }

    void onDraw(SkCanvas* canvas) override {
        // the right edge of the last drawn path
        SkPoint offset = { 0, SkScalarHalf(kMaxPathHeight) };
        if (!fConvexOnly) {
            offset.fY += kMaxOutset;
        }

        for (int i = 0; i < kNumPaths; ++i) {
            this->drawPolygon(canvas, i, &offset);
        }
    }

private:
    static constexpr int kNumPaths = 20;
    static constexpr int kMaxPathHeight = 100;
    static constexpr int kMaxOutset = 16;
    static constexpr int kGMWidth = 512;
    static constexpr int kGMHeight = 512;

    bool fConvexOnly;
    bool fVariableOffset;

    typedef GM INHERITED;
};

//////////////////////////////////////////////////////////////////////////////

DEF_GM(return new PolygonOffsetGM(true, false);)
DEF_GM(return new PolygonOffsetGM(true, true);)
DEF_GM(return new PolygonOffsetGM(false, false);)
DEF_GM(return new PolygonOffsetGM(false, true);)
}