-
Notifications
You must be signed in to change notification settings - Fork 35
/
Path.java
2032 lines (1925 loc) · 82.3 KB
/
Path.java
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
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package io.github.humbleui.skija;
import org.jetbrains.annotations.*;
import io.github.humbleui.skija.impl.*;
import io.github.humbleui.types.*;
/**
* <p>Path contain geometry. Path may be empty, or contain one or more verbs that
* outline a figure. Path always starts with a move verb to a Cartesian coordinate,
* and may be followed by additional verbs that add lines or curves.</p>
*
* <p>Adding a close verb makes the geometry into a continuous loop, a closed contour.
* Path may contain any number of contours, each beginning with a move verb.</p>
*
* <p>Path contours may contain only a move verb, or may also contain lines,
* quadratic beziers, conics, and cubic beziers. Path contours may be open or
* closed.</p>
*
* <p>When used to draw a filled area, Path describes whether the fill is inside or
* outside the geometry. Path also describes the winding rule used to fill
* overlapping contours.</p>
*
* <p>Internally, Path lazily computes metrics likes bounds and convexity. Call
* {@link #updateBoundsCache()} to make Path thread safe.</p>
*/
public class Path extends Managed implements Iterable<PathSegment> {
static { Library.staticLoad(); }
@ApiStatus.Internal
public static class _FinalizerHolder {
public static final long PTR = _nGetFinalizer();
}
/**
* Constructs an empty Path. By default, Path has no verbs, no {@link Point}, and no weights.
* FillMode is set to {@link PathFillMode#WINDING}.
*/
public Path() {
this(_nMake());
Stats.onNativeCall();
}
@NotNull
public static Path makeFromSVGString(String svg) {
long res = _nMakeFromSVGString(svg);
if (res == 0)
throw new IllegalArgumentException("Failed to parse SVG Path string: " + svg);
else
return new Path(res);
}
/**
* Compares this path and o; Returns true if {@link PathFillMode}, verb array, Point array, and weights
* are equivalent.
*
* @param other Path to compare
* @return true if this and Path are equivalent
*/
@ApiStatus.Internal @Override
public boolean _nativeEquals(Native other) {
try {
return _nEquals(_ptr, Native.getPtr(other));
} finally {
ReferenceUtil.reachabilityFence(this);
ReferenceUtil.reachabilityFence(other);
}
}
/**
* <p>Returns true if Path contain equal verbs and equal weights.
* If Path contain one or more conics, the weights must match.</p>
*
* <p>{@link #conicTo(float, float, float, float, float)} may add different verbs
* depending on conic weight, so it is not trivial to interpolate a pair of Path
* containing conics with different conic weight values.</p>
*
* @param compare Path to compare
* @return true if Path verb array and weights are equivalent
*
* @see <a href="https://fiddle.skia.org/c/@Path_isInterpolatable">https://fiddle.skia.org/c/@Path_isInterpolatable</a>
*/
public boolean isInterpolatable(Path compare) {
try {
Stats.onNativeCall();
return _nIsInterpolatable(_ptr, Native.getPtr(compare));
} finally {
ReferenceUtil.reachabilityFence(this);
ReferenceUtil.reachabilityFence(compare);
}
}
/**
* <p>Interpolates between Path with {@link Point} array of equal size.
* Copy verb array and weights to out, and set out Point array to a weighted
* average of this Point array and ending Point array, using the formula:
*
* <p>{@code (Path Point * weight) + ending Point * (1 - weight)}
*
* <p>weight is most useful when between zero (ending Point array) and
* one (this Point_Array); will work with values outside of this
* range.</p>
*
* <p>interpolate() returns null if Point array is not
* the same size as ending Point array. Call {@link #isInterpolatable(Path)} to check Path
* compatibility prior to calling interpolate().</p>
*
* @param ending Point array averaged with this Point array
* @param weight contribution of this Point array, and
* one minus contribution of ending Point array
* @return interpolated Path if Path contain same number of Point, null otherwise
*
* @see <a href="https://fiddle.skia.org/c/@Path_interpolate">https://fiddle.skia.org/c/@Path_interpolate</a>
*/
public Path makeLerp(Path ending, float weight) {
try {
Stats.onNativeCall();
long ptr = _nMakeLerp(_ptr, Native.getPtr(ending), weight);
if (ptr == 0)
throw new IllegalArgumentException("Point array is not the same size as ending Point array");
return new Path(ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
ReferenceUtil.reachabilityFence(ending);
}
}
public PathFillMode getFillMode() {
try {
Stats.onNativeCall();
return PathFillMode._values[_nGetFillMode(_ptr)];
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
public Path setFillMode(PathFillMode fillMode) {
Stats.onNativeCall();
_nSetFillMode(_ptr, fillMode.ordinal());
return this;
}
/**
* Returns true if the path is convex. If necessary, it will first compute the convexity.
*
* @return true or false
*/
public boolean isConvex() {
try {
Stats.onNativeCall();
return _nIsConvex(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* Returns oval bounds if this path is recognized as an oval or circle.
*
* @return bounds is recognized as an oval or circle, null otherwise
*
* @see <a href="https://fiddle.skia.org/c/@Path_isOval">https://fiddle.skia.org/c/@Path_isOval</a>
*/
public Rect isOval() {
try {
Stats.onNativeCall();
return _nIsOval(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* Returns {@link RRect} if this path is recognized as an oval, circle or RRect.
*
* @return bounds is recognized as an oval, circle or RRect, null otherwise
*
* @see <a href="https://fiddle.skia.org/c/@Path_isRRect">https://fiddle.skia.org/c/@Path_isRRect</a>
*/
public RRect isRRect() {
try {
Stats.onNativeCall();
return _nIsRRect(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Sets Path to its initial state.</p>
*
* <p>Removes verb array, Point array, and weights, and sets FillMode to {@link PathFillMode#WINDING}.
* Internal storage associated with Path is released.</p>
*
* @return this
*
* @see <a href="https://fiddle.skia.org/c/@Path_reset">https://fiddle.skia.org/c/@Path_reset</a>
*/
public Path reset() {
Stats.onNativeCall();
_nReset(_ptr);
return this;
}
/**
* <p>Sets Path to its initial state, preserving internal storage.
* Removes verb array, Point array, and weights, and sets FillMode to kWinding.
* Internal storage associated with Path is retained.</p>
*
* <p>Use {@link #rewind()} instead of {@link #reset()} if Path storage will be reused and performance
* is critical.</p>
*
* @return this
*
* @see <a href="https://fiddle.skia.org/c/@Path_rewind">https://fiddle.skia.org/c/@Path_rewind</a>
*/
public Path rewind() {
Stats.onNativeCall();
_nRewind(_ptr);
return this;
}
/**
* <p>Returns if Path is empty.</p>
*
* <p>Empty Path may have FillMode but has no {@link Point}, {@link PathVerb}, or conic weight.
* {@link Path()} constructs empty Path; {@link #reset()} and {@link #rewind()} make Path empty.</p>
*
* @return true if the path contains no Verb array
*/
public boolean isEmpty() {
try {
Stats.onNativeCall();
return _nIsEmpty(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Returns if contour is closed.</p>
*
* <p>Contour is closed if Path Verb array was last modified by {@link #closePath()}. When stroked,
* closed contour draws {@link PaintStrokeJoin} instead of {@link PaintStrokeCap} at first and last Point.</p>
*
* @return true if the last contour ends with a {@link PathVerb#CLOSE}
*
* @see <a href="https://fiddle.skia.org/c/@Path_isLastContourClosed">https://fiddle.skia.org/c/@Path_isLastContourClosed</a>
*/
public boolean isLastContourClosed() {
try {
Stats.onNativeCall();
return _nIsLastContourClosed(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* Returns true for finite Point array values between negative Float.MIN_VALUE and
* positive Float.MAX_VALUE. Returns false for any Point array value of
* Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, or Float.NaN.
*
* @return true if all Point values are finite
*/
public boolean isFinite() {
try {
Stats.onNativeCall();
return _nIsFinite(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* Returns true if the path is volatile; it will not be altered or discarded
* by the caller after it is drawn. Path by default have volatile set false, allowing
* {@link Surface} to attach a cache of data which speeds repeated drawing. If true, {@link Surface}
* may not speed repeated drawing.
*
* @return true if caller will alter Path after drawing
*/
public boolean isVolatile() {
try {
Stats.onNativeCall();
return _nIsVolatile(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Specifies whether Path is volatile; whether it will be altered or discarded
* by the caller after it is drawn. Path by default have volatile set false, allowing
* SkBaseDevice to attach a cache of data which speeds repeated drawing.</p>
*
* <p>Mark temporary paths, discarded or modified after use, as volatile
* to inform SkBaseDevice that the path need not be cached.</p>
*
* <p>Mark animating Path volatile to improve performance.
* Mark unchanging Path non-volatile to improve repeated rendering.</p>
*
* <p>raster surface Path draws are affected by volatile for some shadows.
* GPU surface Path draws are affected by volatile for some shadows and concave geometries.</p>
*
* @param isVolatile true if caller will alter Path after drawing
* @return this
*/
public Path setVolatile(boolean isVolatile) {
Stats.onNativeCall();
_nSetVolatile(_ptr, isVolatile);
return this;
}
/**
* <p>Tests if line between Point pair is degenerate.</p>
*
* <p>Line with no length or that moves a very short distance is degenerate; it is
* treated as a point.</p>
*
* <p>exact changes the equality test. If true, returns true only if p1 equals p2.
* If false, returns true if p1 equals or nearly equals p2.</p>
*
* @param p1 line start point
* @param p2 line end point
* @param exact if false, allow nearly equals
* @return true if line is degenerate; its length is effectively zero
*
* @see <a href="https://fiddle.skia.org/c/@Path_IsLineDegenerate">https://fiddle.skia.org/c/@Path_IsLineDegenerate</a>
*/
public static boolean isLineDegenerate(Point p1, Point p2, boolean exact) {
Stats.onNativeCall();
return _nIsLineDegenerate(p1._x, p1._y, p2._x, p2._y, exact);
}
/**
* <p>Tests if quad is degenerate.</p>
*
* <p>Quad with no length or that moves a very short distance is degenerate; it is
* treated as a point.</p>
*
* @param p1 quad start point
* @param p2 quad control point
* @param p3 quad end point
* @param exact if true, returns true only if p1, p2, and p3 are equal;
* if false, returns true if p1, p2, and p3 are equal or nearly equal
* @return true if quad is degenerate; its length is effectively zero
*/
public static boolean isQuadDegenerate(Point p1, Point p2, Point p3, boolean exact) {
Stats.onNativeCall();
return _nIsQuadDegenerate(p1._x, p1._y, p2._x, p2._y, p3._x, p3._y, exact);
}
/**
* <p>Tests if cubic is degenerate.</p>
*
* <p>Cubic with no length or that moves a very short distance is degenerate; it is
* treated as a point.</p>
*
* @param p1 cubic start point
* @param p2 cubic control point 1
* @param p3 cubic control point 2
* @param p4 cubic end point
* @param exact if true, returns true only if p1, p2, p3, and p4 are equal;
* if false, returns true if p1, p2, p3, and p4 are equal or nearly equal
* @return true if cubic is degenerate; its length is effectively zero
*/
public static boolean isCubicDegenerate(Point p1, Point p2, Point p3, Point p4, boolean exact) {
Stats.onNativeCall();
return _nIsCubicDegenerate(p1._x, p1._y, p2._x, p2._y, p3._x, p3._y, p4._x, p4._y, exact);
}
/**
* Returns array of two points if Path contains only one line;
* Verb array has two entries: {@link PathVerb#MOVE}, {@link PathVerb#LINE}.
* Returns null if Path is not one line.
*
* @return Point[2] if Path contains exactly one line, null otherwise
*
* @see <a href="https://fiddle.skia.org/c/@Path_isLine">https://fiddle.skia.org/c/@Path_isLine</a>
*/
public Point[] getAsLine() {
try {
Stats.onNativeCall();
return _nMaybeGetAsLine(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* Returns the number of points in Path.
* Point count is initially zero.
*
* @return Path Point array length
*
* @see <a href="https://fiddle.skia.org/c/@Path_countPoints">https://fiddle.skia.org/c/@Path_countPoints</a>
*/
public int getPointsCount() {
try {
Stats.onNativeCall();
return _nGetPointsCount(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Returns Point at index in Point array. Valid range for index is
* 0 to countPoints() - 1.</p>
*
* <p>Returns (0, 0) if index is out of range.</p>
*
* @param index Point array element selector
* @return Point array value or (0, 0)
*
* @see <a href="https://fiddle.skia.org/c/@Path_getPoint">https://fiddle.skia.org/c/@Path_getPoint</a>
*/
public Point getPoint(int index) {
try {
Stats.onNativeCall();
return _nGetPoint(_ptr, index);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Returns all points in Path.</p>
*
* @return Path Point array length
*
* @see <a href="https://fiddle.skia.org/c/@Path_getPoints">https://fiddle.skia.org/c/@Path_getPoints</a>
*/
public Point[] getPoints() {
Point[] res = new Point[getPointsCount()];
getPoints(res, res.length);
return res;
}
/**
* <p>Returns number of points in Path. Up to max points are copied.</p>
*
* <p>points may be null; then, max must be zero.
* If max is greater than number of points, excess points storage is unaltered.</p>
*
* @param points storage for Path Point array. May be null
* @param max maximum to copy; must be greater than or equal to zero
* @return Path Point array length
*
* @see <a href="https://fiddle.skia.org/c/@Path_getPoints">https://fiddle.skia.org/c/@Path_getPoints</a>
*/
public int getPoints(Point[] points, int max) {
try {
assert points == null ? max == 0 : true;
Stats.onNativeCall();
return _nGetPoints(_ptr, points, max);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* Returns the number of verbs: {@link PathVerb#MOVE}, {@link PathVerb#LINE}, {@link PathVerb#QUAD}, {@link PathVerb#CONIC},
* {@link PathVerb#CUBIC}, and {@link PathVerb#CLOSE}; added to Path.
*
* @return length of verb array
*
* @see <a href="https://fiddle.skia.org/c/@Path_countVerbs">https://fiddle.skia.org/c/@Path_countVerbs</a>
*/
public int getVerbsCount() {
try {
Stats.onNativeCall();
return _nCountVerbs(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
public PathVerb[] getVerbs() {
PathVerb[] res = new PathVerb[getVerbsCount()];
getVerbs(res, res.length);
return res;
}
/**
* Returns the number of verbs in the path. Up to max verbs are copied.
*
* @param verbs storage for verbs, may be null
* @param max maximum number to copy into verbs
* @return the actual number of verbs in the path
*
* @see <a href="https://fiddle.skia.org/c/@Path_getVerbs">https://fiddle.skia.org/c/@Path_getVerbs</a>
*/
public int getVerbs(PathVerb[] verbs, int max) {
try {
assert verbs == null ? max == 0 : true;
Stats.onNativeCall();
byte[] out = verbs == null ? null : new byte[max];
int count = _nGetVerbs(_ptr, out, max);
if (verbs != null)
for (int i = 0; i < Math.min(count, max); ++i)
verbs[i] = PathVerb._values[out[i]];
return count;
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* Returns the approximate byte size of the Path in memory.
*
* @return approximate size
*/
public long getApproximateBytesUsed() {
try {
Stats.onNativeCall();
return _nApproximateBytesUsed(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Exchanges the verb array, Point array, weights, and FillMode with other.
* Cached state is also exchanged. swap() internally exchanges pointers, so
* it is lightweight and does not allocate memory.</p>
*
* @param other Path exchanged by value
* @return this
*
* @see <a href="https://fiddle.skia.org/c/@Path_swap">https://fiddle.skia.org/c/@Path_swap</a>
*/
public Path swap(Path other) {
try {
Stats.onNativeCall();
_nSwap(_ptr, Native.getPtr(other));
return this;
} finally {
ReferenceUtil.reachabilityFence(other);
}
}
/**
* <p>Returns minimum and maximum axes values of Point array.</p>
*
* <p>Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may
* be larger or smaller than area affected when Path is drawn.</p>
*
* <p>Rect returned includes all Point added to Path, including Point associated with
* {@link PathVerb#MOVE} that define empty contours.</p>
*
* @return bounds of all Point in Point array
*/
public Rect getBounds() {
try {
Stats.onNativeCall();
return _nGetBounds(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Updates internal bounds so that subsequent calls to {@link #getBounds()} are instantaneous.
* Unaltered copies of Path may also access cached bounds through {@link #getBounds()}.</p>
*
* <p>For now, identical to calling {@link #getBounds()} and ignoring the returned value.</p>
*
* <p>Call to prepare Path subsequently drawn from multiple threads,
* to avoid a race condition where each draw separately computes the bounds.</p>
*
* @return this
*/
public Path updateBoundsCache() {
Stats.onNativeCall();
_nUpdateBoundsCache(_ptr);
return this;
}
/**
* <p>Returns minimum and maximum axes values of the lines and curves in Path.
* Returns (0, 0, 0, 0) if Path contains no points.
* Returned bounds width and height may be larger or smaller than area affected
* when Path is drawn.</p>
*
* <p>Includes Point associated with {@link PathVerb#MOVE} that define empty
* contours.</p>
*
* Behaves identically to {@link #getBounds()} when Path contains
* only lines. If Path contains curves, computed bounds includes
* the maximum extent of the quad, conic, or cubic; is slower than {@link #getBounds()};
* and unlike {@link #getBounds()}, does not cache the result.
*
* @return tight bounds of curves in Path
*
* @see <a href="https://fiddle.skia.org/c/@Path_computeTightBounds">https://fiddle.skia.org/c/@Path_computeTightBounds</a>
*/
public Rect computeTightBounds() {
try {
Stats.onNativeCall();
return _nComputeTightBounds(_ptr);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Returns true if rect is contained by Path.
* May return false when rect is contained by Path.</p>
*
* <p>For now, only returns true if Path has one contour and is convex.
* rect may share points and edges with Path and be contained.
* Returns true if rect is empty, that is, it has zero width or height; and
* the Point or line described by rect is contained by Path.</p>
*
* @param rect Rect, line, or Point checked for containment
* @return true if rect is contained
*
* @see <a href="https://fiddle.skia.org/c/@Path_conservativelyContainsRect">https://fiddle.skia.org/c/@Path_conservativelyContainsRect</a>
*/
public boolean conservativelyContainsRect(Rect rect) {
try {
Stats.onNativeCall();
return _nConservativelyContainsRect(_ptr, rect._left, rect._top, rect._right, rect._bottom);
} finally {
ReferenceUtil.reachabilityFence(this);
}
}
/**
* <p>Grows Path verb array and Point array to contain extraPtCount additional Point.
* May improve performance and use less memory by
* reducing the number and size of allocations when creating Path.</p>
*
* @param extraPtCount number of additional Point to allocate
* @return this
*
* @see <a href="https://fiddle.skia.org/c/@Path_incReserve">https://fiddle.skia.org/c/@Path_incReserve</a>
*/
public Path incReserve(int extraPtCount) {
Stats.onNativeCall();
_nIncReserve(_ptr, extraPtCount);
return this;
}
/**
* Adds beginning of contour at Point (x, y).
*
* @param x x-axis value of contour start
* @param y y-axis value of contour start
* @return reference to Path
*
* @see <a href="https://fiddle.skia.org/c/@Path_moveTo">https://fiddle.skia.org/c/@Path_moveTo</a>
*/
public Path moveTo(float x, float y) {
Stats.onNativeCall();
_nMoveTo(_ptr, x, y);
return this;
}
/**
* Adds beginning of contour at Point p.
*
* @param p contour start
* @return this
*/
public Path moveTo(Point p) {
return moveTo(p._x, p._y);
}
/**
* <p>Adds beginning of contour relative to last point.</p>
*
* <p>If Path is empty, starts contour at (dx, dy).
* Otherwise, start contour at last point offset by (dx, dy).
* Function name stands for "relative move to".</p>
*
* @param dx offset from last point to contour start on x-axis
* @param dy offset from last point to contour start on y-axis
* @return reference to Path
*
* @see <a href="https://fiddle.skia.org/c/@Path_rMoveTo">https://fiddle.skia.org/c/@Path_rMoveTo</a>
*/
public Path rMoveTo(float dx, float dy) {
Stats.onNativeCall();
_nRMoveTo(_ptr, dx, dy);
return this;
}
/**
* <p>Adds line from last point to (x, y). If Path is empty, or last Verb is
* {@link PathVerb#CLOSE}, last point is set to (0, 0) before adding line.</p>
*
* <p>lineTo() appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed.
* lineTo() then appends {@link PathVerb#LINE} to verb array and (x, y) to Point array.</p>
*
* @param x end of added line on x-axis
* @param y end of added line on y-axis
* @return this
*
* @see <a href="https://fiddle.skia.org/c/@Path_lineTo">https://fiddle.skia.org/c/@Path_lineTo</a>
*/
public Path lineTo(float x, float y) {
Stats.onNativeCall();
_nLineTo(_ptr, x, y);
return this;
}
/**
* <p>Adds line from last point to Point p. If Path is empty, or last {@link PathVerb} is
* {@link PathVerb#CLOSE}, last point is set to (0, 0) before adding line.</p>
*
* <p>lineTo() first appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed.
* lineTo() then appends {@link PathVerb#LINE} to verb array and Point p to Point array.</p>
*
* @param p end Point of added line
* @return reference to Path
*/
public Path lineTo(Point p) {
return lineTo(p._x, p._y);
}
/**
* <p>Adds line from last point to vector (dx, dy). If Path is empty, or last {@link PathVerb} is
* {@link PathVerb#CLOSE}, last point is set to (0, 0) before adding line.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed;
* then appends {@link PathVerb#LINE} to verb array and line end to Point array.</p>
*
* <p>Line end is last point plus vector (dx, dy).</p>
*
* <p>Function name stands for "relative line to".</p>
*
* @param dx offset from last point to line end on x-axis
* @param dy offset from last point to line end on y-axis
* @return reference to Path
*
* @see <a href="https://fiddle.skia.org/c/@Path_rLineTo">https://fiddle.skia.org/c/@Path_rLineTo</a>
* @see <a href="https://fiddle.skia.org/c/@Quad_a">https://fiddle.skia.org/c/@Quad_a</a>
* @see <a href="https://fiddle.skia.org/c/@Quad_b">https://fiddle.skia.org/c/@Quad_b</a>
*/
public Path rLineTo(float dx, float dy) {
Stats.onNativeCall();
_nRLineTo(_ptr, dx, dy);
return this;
}
/**
* Adds quad from last point towards (x1, y1), to (x2, y2).
* If Path is empty, or last {@link PathVerb} is {@link PathVerb#CLOSE}, last point is set to (0, 0)
* before adding quad.
*
* Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed;
* then appends {@link PathVerb#QUAD} to verb array; and (x1, y1), (x2, y2)
* to Point array.
*
* @param x1 control Point of quad on x-axis
* @param y1 control Point of quad on y-axis
* @param x2 end Point of quad on x-axis
* @param y2 end Point of quad on y-axis
* @return reference to Path
*
* @see <a href="https://fiddle.skia.org/c/@Path_quadTo">https://fiddle.skia.org/c/@Path_quadTo</a>
*/
public Path quadTo(float x1, float y1, float x2, float y2) {
Stats.onNativeCall();
_nQuadTo(_ptr, x1, y1, x2, y2);
return this;
}
/**
* <p>Adds quad from last point towards Point p1, to Point p2.</p>
*
* <p>If Path is empty, or last {@link PathVerb} is {@link PathVerb#CLOSE}, last point is set to (0, 0)
* before adding quad.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed;
* then appends {@link PathVerb#QUAD} to verb array; and Point p1, p2
* to Point array.</p>
*
* @param p1 control Point of added quad
* @param p2 end Point of added quad
* @return reference to Path
*/
public Path quadTo(Point p1, Point p2) {
return quadTo(p1._x, p1._y, p2._x, p2._y);
}
/**
* <p>Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2).
* If Path is empty, or last {@link PathVerb}
* is {@link PathVerb#CLOSE}, last point is set to (0, 0) before adding quad.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array,
* if needed; then appends {@link PathVerb#QUAD} to verb array; and appends quad
* control and quad end to Point array.</p>
*
* <p>Quad control is last point plus vector (dx1, dy1).</p>
*
* <p>Quad end is last point plus vector (dx2, dy2).</p>
*
* <p>Function name stands for "relative quad to".</p>
*
* @param dx1 offset from last point to quad control on x-axis
* @param dy1 offset from last point to quad control on y-axis
* @param dx2 offset from last point to quad end on x-axis
* @param dy2 offset from last point to quad end on y-axis
* @return reference to Path
*
* @see <a href="https://fiddle.skia.org/c/@Conic_Weight_a">https://fiddle.skia.org/c/@Conic_Weight_a</a>
* @see <a href="https://fiddle.skia.org/c/@Conic_Weight_b">https://fiddle.skia.org/c/@Conic_Weight_b</a>
* @see <a href="https://fiddle.skia.org/c/@Conic_Weight_c">https://fiddle.skia.org/c/@Conic_Weight_c</a>
* @see <a href="https://fiddle.skia.org/c/@Path_rQuadTo">https://fiddle.skia.org/c/@Path_rQuadTo</a>
*/
public Path rQuadTo(float dx1, float dy1, float dx2, float dy2) {
Stats.onNativeCall();
_nRQuadTo(_ptr, dx1, dy1, dx2, dy2);
return this;
}
/**
* <p>Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.</p>
*
* <p>If Path is empty, or last {@link PathVerb} is {@link PathVerb#CLOSE}, last point is set to (0, 0)
* before adding conic.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed.</p>
*
* <p>If w is finite and not one, appends {@link PathVerb#CONIC} to verb array;
* and (x1, y1), (x2, y2) to Point array; and w to conic weights.</p>
*
* <p>If w is one, appends {@link PathVerb#QUAD} to verb array, and
* (x1, y1), (x2, y2) to Point array.</p>
*
* <p>If w is not finite, appends {@link PathVerb#LINE} twice to verb array, and
* (x1, y1), (x2, y2) to Point array.</p>
*
* @param x1 control Point of conic on x-axis
* @param y1 control Point of conic on y-axis
* @param x2 end Point of conic on x-axis
* @param y2 end Point of conic on y-axis
* @param w weight of added conic
* @return reference to Path
*/
public Path conicTo(float x1, float y1, float x2, float y2, float w) {
Stats.onNativeCall();
_nConicTo(_ptr, x1, y1, x2, y2, w);
return this;
}
/**
* <p>Adds conic from last point towards Point p1, to Point p2, weighted by w.</p>
*
* <p>If Path is empty, or last {@link PathVerb} is {@link PathVerb#CLOSE}, last point is set to (0, 0)
* before adding conic.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed.</p>
*
* <p>If w is finite and not one, appends {@link PathVerb#CONIC} to verb array;
* and Point p1, p2 to Point array; and w to conic weights.</p>
*
* <p>If w is one, appends {@link PathVerb#QUAD} to verb array, and Point p1, p2
* to Point array.</p>
*
* <p>If w is not finite, appends {@link PathVerb#LINE} twice to verb array, and
* Point p1, p2 to Point array.</p>
*
* @param p1 control Point of added conic
* @param p2 end Point of added conic
* @param w weight of added conic
* @return reference to Path
*/
public Path conicTo(Point p1, Point p2, float w) {
return conicTo(p1._x, p1._y, p2._x, p2._y, w);
}
/**
* <p>Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2),
* weighted by w. If Path is empty, or last {@link PathVerb}
* is {@link PathVerb#CLOSE}, last point is set to (0, 0) before adding conic.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array,
* if needed.</p>
*
* <p>If w is finite and not one, next appends {@link PathVerb#CONIC} to verb array,
* and w is recorded as conic weight; otherwise, if w is one, appends
* {@link PathVerb#QUAD} to verb array; or if w is not finite, appends {@link PathVerb#LINE}
* twice to verb array.</p>
*
* <p>In all cases appends Point control and end to Point array.
* control is last point plus vector (dx1, dy1).
* end is last point plus vector (dx2, dy2).</p>
*
* <p>Function name stands for "relative conic to".</p>
*
* @param dx1 offset from last point to conic control on x-axis
* @param dy1 offset from last point to conic control on y-axis
* @param dx2 offset from last point to conic end on x-axis
* @param dy2 offset from last point to conic end on y-axis
* @param w weight of added conic
* @return reference to Path
*/
public Path rConicTo(float dx1, float dy1, float dx2, float dy2, float w) {
Stats.onNativeCall();
_nRConicTo(_ptr, dx1, dy1, dx2, dy2, w);
return this;
}
/**
* <p>Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at
* (x3, y3). If Path is empty, or last {@link PathVerb} is {@link PathVerb#CLOSE}, last point is set to
* (0, 0) before adding cubic.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed;
* then appends {@link PathVerb#CUBIC} to verb array; and (x1, y1), (x2, y2), (x3, y3)
* to Point array.</p>
*
* @param x1 first control Point of cubic on x-axis
* @param y1 first control Point of cubic on y-axis
* @param x2 second control Point of cubic on x-axis
* @param y2 second control Point of cubic on y-axis
* @param x3 end Point of cubic on x-axis
* @param y3 end Point of cubic on y-axis
* @return reference to Path
*/
public Path cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) {
Stats.onNativeCall();
_nCubicTo(_ptr, x1, y1, x2, y2, x3, y3);
return this;
}
/**
* <p>Adds cubic from last point towards Point p1, then towards Point p2, ending at
* Point p3. If Path is empty, or last {@link PathVerb} is {@link PathVerb#CLOSE}, last point is set to
* (0, 0) before adding cubic.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array, if needed;
* then appends {@link PathVerb#CUBIC} to verb array; and Point p1, p2, p3
* to Point array.</p>
*
* @param p1 first control Point of cubic
* @param p2 second control Point of cubic
* @param p3 end Point of cubic
* @return reference to Path
*/
public Path cubicTo(Point p1, Point p2, Point p3) {
return cubicTo(p1._x, p1._y, p2._x, p2._y, p3._x, p3._y);
}
/**
* <p>Adds cubic from last point towards vector (dx1, dy1), then towards
* vector (dx2, dy2), to vector (dx3, dy3).
* If Path is empty, or last {@link PathVerb}
* is {@link PathVerb#CLOSE}, last point is set to (0, 0) before adding cubic.</p>
*
* <p>Appends {@link PathVerb#MOVE} to verb array and (0, 0) to Point array,
* if needed; then appends {@link PathVerb#CUBIC} to verb array; and appends cubic
* control and cubic end to Point array.</p>
*
* <p>Cubic control is last point plus vector (dx1, dy1).</p>
*
* <p>Cubic end is last point plus vector (dx2, dy2).</p>
*
* <p>Function name stands for "relative cubic to".</p>
*
* @param dx1 offset from last point to first cubic control on x-axis
* @param dy1 offset from last point to first cubic control on y-axis
* @param dx2 offset from last point to second cubic control on x-axis
* @param dy2 offset from last point to second cubic control on y-axis
* @param dx3 offset from last point to cubic end on x-axis
* @param dy3 offset from last point to cubic end on y-axis
* @return reference to Path
*/
public Path rCubicTo(float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) {
Stats.onNativeCall();
_nRCubicTo(_ptr, dx1, dy1, dx2, dy2, dx3, dy3);
return this;
}
/**
* <p>Appends arc to Path. Arc added is part of ellipse
* bounded by oval, from startAngle through sweepAngle. Both startAngle and
* sweepAngle are measured in degrees, where zero degrees is aligned with the
* positive x-axis, and positive sweeps extends arc clockwise.</p>
*
* <p>arcTo() adds line connecting Path last Point to initial arc Point if forceMoveTo
* is false and Path is not empty. Otherwise, added contour begins with first point
* of arc. Angles greater than -360 and less than 360 are treated modulo 360.</p>
*
* @param oval bounds of ellipse containing arc
* @param startAngle starting angle of arc in degrees
* @param sweepAngle sweep, in degrees. Positive is clockwise; treated modulo 360
* @param forceMoveTo true to start a new contour with arc
* @return reference to Path
*
* @see <a href="https://fiddle.skia.org/c/@Path_arcTo">https://fiddle.skia.org/c/@Path_arcTo</a>
*/
public Path arcTo(Rect oval, float startAngle, float sweepAngle, boolean forceMoveTo) {
Stats.onNativeCall();
_nArcTo(_ptr, oval._left, oval._top, oval._right, oval._bottom, startAngle, sweepAngle, forceMoveTo);