-
Notifications
You must be signed in to change notification settings - Fork 3
/
FigGeometry.m
1728 lines (1078 loc) · 59.2 KB
/
FigGeometry.m
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:: *)
(*Header comments*)
(* :Title: FigGeometry *)
(* :Context: SciDraw` *)
(* :Summary: Geometry utilities needed by figure objects *)
(* :Author: Mark A. Caprio, Department of Physics, University of Notre Dame *)
(* :Copyright: Copyright FIGYEAR, Mark A. Caprio *)
(* :Package Version: FIGVERSION *)
(* :Mathematica Version: MATHVERSION *)
(* :Discussion: FIGDISCUSSION *)
(* :History: See main package file. *)
(*Begin package*)
(*Package context definition*)
BeginPackage["SciDraw`",SciDraw`Private`$ExternalContexts];
Unprotect[Evaluate[$Context<>"*"]];
(*Begin private context*)
Begin["`Private`"];
(*Dependencies*)
(*Scalar/range/region arithmetic*)
(*Single parameter upgrades*)
ScalarParameterPattern=None|(_?NumericQ);
NonNegativeScalarParameterPattern=(None|NonNegativePattern);
UpgradeScalar[None]:=0;
UpgradeScalar[x_?NumericQ]:=x;
(*Interval rescaling*)
(*lambda wrapper for Rescale[u,{u1,u2},{v1,v2}]*)
(* returns v1+(u-u1)/(u2-u1)*(v2-v1)*)
RescaleInterval[{u1_?NumericQ,u2_?NumericQ},{v1_?NumericQ,v2_?NumericQ}][u_?NumericQ]:=Rescale[u,{u1,u2},{v1,v2}];
(*Range testing*)
InRange[{x1_,x2_},x_]:=(x1<=x)&&(x<=x2);
InRange[{{x1_,x2_},{y1_,y2_}},{x_,y_}]:=InRange[{x1,x2},x]&&InRange[{y1,y2},y];
(*Interval extension by coordinate amount*)
(*1-dimensional*)
(*Note: "Absolute" is SciDraw`Private legacy name. Abs is accepted as global alternative.*)
ExtendInterval[PRange:{_?NumericQ,_?NumericQ},PDiff:{_?NumericQ,_?NumericQ},Mode:(Abs|Absolute)]:=PRange+PDiff*{-1,+1};
ExtendInterval[PRange:{_?NumericQ,_?NumericQ},PFrac:{_?NumericQ,_?NumericQ},Mode:Scaled]:=PRange+PFrac*{-1,+1}*-Subtract@@PRange;
(*Vector geometry*)
(*Trigonometry for 2D vectors*)
VectorLength[{x_?NumericQ,y_?NumericQ}]:=Sqrt[x^2+y^2];VectorArcTan[{x_?NumericQ,y_?NumericQ}]:=If[{x,y}=={0,0},0.,ArcTan[x,y]];
SegmentLength[{p1:{_?NumericQ,_?NumericQ},p2:{_?NumericQ,_?NumericQ}}]:=VectorLength[p2-p1];
SegmentTangent[{p1:{_?NumericQ,_?NumericQ},p2:{_?NumericQ,_?NumericQ}}]:=(p2-p1)/VectorLength[p2-p1];SegmentArcTan[{p1:{_?NumericQ,_?NumericQ},p2:{_?NumericQ,_?NumericQ}}]:=VectorArcTan[p2-p1];
FromPolar[{rho_,phi_}]:=rho*{Cos[phi],Sin[phi]};
(*Segment interpolation*)
(*Null segment*)
InterpolateSegment[
s:{p1:{_?NumericQ,_?NumericQ},p2:{_?NumericQ,_?NumericQ}},
Reference:(Tail|Center|Head),Mode:(Absolute|Scaled):Scaled,
x_?NumericQ
]/;(Chop[SegmentLength[s]]==0):=p1;
(*Generic segment*)
(* Curve parameter is always in the *forward* direction (tail to head).*)
(* Mappings for scaled coordinates:*)
(* Tail [0,+1] -> [p1,p2]*)
(* Center [-1,+1] -> [p1,p2] -- so units are scaled by factor of two relative to other cases, consistent with "offset" relative position*)
(* Head [-1,0] -> [p1,p2]*)
InterpolateSegment[
s:{p1:{_?NumericQ,_?NumericQ},p2:{_?NumericQ,_?NumericQ}},
Reference:Tail,
Mode:(Absolute|Scaled):Scaled,
x_?NumericQ
]/;(Chop[SegmentLength[s]]!=0):=p1+x*(p2-p1)/Switch[Mode,Absolute,SegmentLength[s],Scaled,1];
InterpolateSegment[
s:{p1:{_?NumericQ,_?NumericQ},p2:{_?NumericQ,_?NumericQ}},
Reference:Center,
Mode:(Absolute|Scaled):Scaled,
x_?NumericQ
]/;(Chop[SegmentLength[s]]!=0):=(p2+p1)/2+x*(p2-p1)/Switch[Mode,Absolute,SegmentLength[s],Scaled,2];
InterpolateSegment[
s:{p1:{_?NumericQ,_?NumericQ},p2:{_?NumericQ,_?NumericQ}},
Reference:Head,
Mode:(Absolute|Scaled):Scaled,
x_?NumericQ
]/;(Chop[SegmentLength[s]]!=0):=p2+x*(p2-p1)/Switch[Mode,Absolute,SegmentLength[s],Scaled,1];
(*XY pair geometry*)
(*Numerical pair pattern*)
(*Explicit numerical {x,y} pair*)
(*Note: Text should use FigTextOffsetPattern instead, which allows the value Automatic as well.*)
NumericalPairPattern={_?NumericQ,_?NumericQ};
(*Pair parameter upgrades*)
(*Generic upgrade to equal values -- appropriate for radii and most types of nonnumeric parameters*)
UpgradePair[a:NonListPattern]:={a,a};
UpgradePair[{x:NonListPattern,y:NonListPattern}]:={x,y};
(*Upgrade to default horizontal or default vertical numerical pair -- as in classic Nudge behavior*)
IntervalParametersPattern=(None|(_?NumericQ)|{(_?NumericQ),(_?NumericQ)});
NonNegativeIntervalParametersPattern=(None|NonNegativePattern|{NonNegativePattern,NonNegativePattern});
UpgradePairEqual[None]:={0,0};
UpgradePairEqual[x_?NumericQ]:={x,x};
UpgradePairEqual[{x_?NumericQ,y_?NumericQ}]:={x,y};
UpgradePairHorizontal[None]:={0,0};
UpgradePairHorizontal[x_?NumericQ]:={x,0};
UpgradePairHorizontal[{x_?NumericQ,y_?NumericQ}]:={x,y};
UpgradePairVertical[None]:={0,0};
UpgradePairVertical[y_?NumericQ]:={0,y};
UpgradePairVertical[{x_?NumericQ,y_?NumericQ}]:={x,y};
(*Point/anchor geometry*)
(*Point pattern*)
(*Point specification (including anchor name or object anchor generation).*)
FigCoordinatePointPattern={
((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)]),
((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)])
}|(Scaled|Absolute)[{_?NumericQ,_?NumericQ}];
FigPointPattern=(FigCoordinatePointPattern|ObjectPattern[FigAnchor]|ObjectNamePattern[FigAnchor]);
(*Point resolution*)
(*Resolves a point/anchor specification into canvas coordinates.*)
(**)
(*Note: This function is technically not necessary, since any valid point specification can be converted to an anchor with FigAnchor[p], and then the point part of the anchor can be extracted. However, this function is more direct for ordinary numerical points, in that it avoids unnecessary creation of anchors for these points.*)
FigResolvePoint[p:{_?NumericQ,_?NumericQ}]:=(CurrentWindow[]@TFunction[])@p;
FigResolvePoint[Absolute[p:{_?NumericQ,_?NumericQ}]]:=p;
FigResolvePoint[Scaled[p:{_?NumericQ,_?NumericQ}]]:=(CurrentWindow[]@ScaledTFunction[])@p;
FigResolvePoint[a:ObjectPattern[FigAnchor]]:=a@GetPoint[];
FigResolvePoint[n:ObjectNamePattern[FigAnchor]]:=Object[n]@GetPoint[];
(*Ad hoc treatment of hybrid coordinates*)
FigResolvePoint[
p:Except[
{_?NumericQ,_?NumericQ},
{
x:((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)]),
y:((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)])
}
]
]:={FigResolveCoordinate[x,1],FigResolveCoordinate[y,2]};
(*Generic bounding box generation for point-like objects*)
FigPointBoundingBox[p:{x_?NumericQ,y_?NumericQ}]:={{x,x},{y,y}};
(*Displacement geometry*)
(*A "displacement" is a difference of positions, i.e., a vector describing a translation*)
(*Displacement patterns*)
FigDisplacementPattern=None|({_?NumericQ,_?NumericQ}|Scaled[{_?NumericQ,_?NumericQ}]|Absolute[{_?NumericQ,_?NumericQ}])|{
((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)]),
((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)])
};
FigDisplacementSequencePattern[n_Integer]:=Repeated[_?(MatchQ[#,FigDisplacementPattern]&),{n,Infinity}];
FigDisplacementSetPattern[n_Integer]:={Repeated[_?(MatchQ[#,FigDisplacementPattern]&),{n,Infinity}]};
(*FigResolveDisplacement*)
FigResolveDisplacement[None]:={0,0};
FigResolveDisplacement[d:{_?NumericQ,_?NumericQ}]:=(CurrentWindow[]@DeltaTFunction[])@d;
FigResolveDisplacement[Absolute[d:{_?NumericQ,_?NumericQ}]]:=d;
FigResolveDisplacement[Scaled[d:{_?NumericQ,_?NumericQ}]]:=(CurrentWindow[]@ScaledDeltaTFunction[])@d;
(*Ad hoc treatment of hybrid coordinates*)
FigResolveDisplacement[
p:Except[
{_?NumericQ,_?NumericQ},
{
x:((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)]),
y:((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)])
}
]
]:={FigResolveCoordinateDisplacement[x,1],FigResolveCoordinateDisplacement[y,2]};
(*Offset geometry*)
(*An "offset" is a relative position within a rectangle*)
(*Named point offsets*)
(*Note: These are the offsets to the point. The offset of text attached to the point should be the negative of this.*)
NamedPointPattern=Center|Left|Right|Bottom|Top|TopLeft|TopRight|BottomLeft|BottomRight;
NamedPointOffset[Center]={0,0};
NamedPointOffset[Left]={-1,0};
NamedPointOffset[Right]={+1,0};
NamedPointOffset[Bottom]={0,-1};
NamedPointOffset[Top]={0,+1};
NamedPointOffset[TopLeft]={-1,+1};
NamedPointOffset[TopRight]={+1,+1};
NamedPointOffset[BottomLeft]={-1,-1};
NamedPointOffset[BottomRight]={+1,-1};
(*Realizing offset*)
FigOffsetPattern=NamedPointPattern|NumericalPairPattern;
FigResolveOffset[Offset:NamedPointPattern]:=NamedPointOffset[Offset];
FigResolveOffset[Offset:NumericalPairPattern]:=Offset;
(*Window/panel geometry*)
(*Generic numerical region pattern*)
RangeParametersPattern=(None|(_?NumericQ)|{(_?NumericQ),(_?NumericQ)}|{{(_?NumericQ),(_?NumericQ)},{(_?NumericQ),(_?NumericQ)}});
NonNegativeRangeParametersPattern=(None|NonNegativePattern|{NonNegativePattern,NonNegativePattern}|{{NonNegativePattern,NonNegativePattern},{NonNegativePattern,NonNegativePattern}});
NumericalRegionPattern={{(_?NumericQ),(_?NumericQ)},{(_?NumericQ),(_?NumericQ)}};
(*Generic numerical region upgrade*)
(*for numeric data*)
(**)
(*general rules*)
(* x -> {x,x}*)
(* {x,y} -> {{x,x},{y,y}}*)
(* {{x1,x2},{y1,y2}} left unchanged*)
(* *)
(*special case*)
(* None -> {{0,0},{0,0}}*)
UpgradeRangeParameters[xy_?NumericQ]:=UpgradeRangeParameters[{xy,xy}];
UpgradeRangeParameters[{x_?NumericQ,y_?NumericQ}]:=UpgradeRangeParameters[{{x,x},{y,y}}];
UpgradeRangeParameters[{{x1_?NumericQ,x2_?NumericQ},{y1_?NumericQ,y2_?NumericQ}}]:={{x1,x2},{y1,y2}};
UpgradeRangeParameters[None]={{0,0},{0,0}};
(*Region extension by coordinate amount*)
(*2-dimensional*)
(*Note: "Absolute" is SciDraw`Private legacy name. Abs is accepted as global alternative.*)
ExtendRegion[PRange:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},PDiff:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},Mode:(Abs|Absolute)]:=PRange+PDiff*{{-1,+1},{-1,+1}};
ExtendRegion[PRange:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},PFrac:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},Mode:Scaled]:=PRange+PFrac*{{-1,+1},{-1,+1}}*-Subtract@@@PRange;
(*Window region specification pattern*)
(*Note: Pattern excludes case {_Integer,_Integer}, for panel in multipanel array, since this case requires special treatment.*)
FigRegionPattern=(All|{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}}|(Scaled|Absolute)[{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}}]);
(*Region resolution*)
FigResolveRegion[r:All]:=(CurrentWindow[]@CanvasRegion[]);
FigResolveRegion[r:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}}]:=TransformRegion[CurrentWindow[]@TFunction[],r];
FigResolveRegion[Absolute[r:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}}]]:=r;
FigResolveRegion[Scaled[r:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}}]]:=TransformRegion[CurrentWindow[]@ScaledTFunction[],r];
(*Region extension*)
(*Programmer level functions -- working in canvas coordinates*)
(*Serve to resolve "delta region patterns" to adjustments which can be handled arithmetically by ExtendRegion*)
(*Here "Scaled" refers to a fraction of the region which is being expanded, not of the current window.*)
(*FigResolveRegionExtension converts a user-acceptable region extension and returns arguments {{{x1,x2},{y1,y2}},{dx1,dx2},{dy1,dy2},Absolute|Scaled} for use with ExtendRegion.*)
FigResolveRegionExtension[r:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},d:None]:={r,UpgradeRangeParameters[0],Absolute};
FigResolveRegionExtension[r:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},d:Automatic]:={r,UpgradeRangeParameters[0.02],Scaled};
FigResolveRegionExtension[r:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},d:RangeParametersPattern]:={r,TransformRegion[CurrentWindow[]@DeltaTFunction[],UpgradeRangeParameters[d]],Absolute};
FigResolveRegionExtension[r:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},Absolute[d:RangeParametersPattern]]:={r,UpgradeRangeParameters[d],Absolute};
FigResolveRegionExtension[r:{{_?NumericQ,_?NumericQ},{_?NumericQ,_?NumericQ}},Scaled[d:RangeParametersPattern]]:={r,UpgradeRangeParameters[d],Scaled};
(*General adjustment of region*)
(*User-level wrapper*)
(* Returns result as valid region specification, wrapped in Canvas[]*)
FigDeltaRegionPattern=Automatic|None|RangeParametersPattern|(Scaled|Absolute)[RangeParametersPattern];
Options[AdjustRegion]={RegionExtension->None,RegionDisplacement->None};
AdjustRegion[r:FigRegionPattern,Opts___?OptionQ]:=Module[
{
FullOptions=Flatten[{Opts,Options[AdjustRegion]}],CanvasRegion
},
(* validate options *)
FigCheckOption[AdjustRegion,RegionDisplacement,FigDisplacementPattern,FullOptions];
FigCheckOption[AdjustRegion,RegionExtension,FigDeltaRegionPattern,FullOptions];
(* resolve given region to canvas coordinates *)
CanvasRegion=FigResolveRegion[r];
(* do displacement *)
CanvasRegion=CanvasRegion+FigResolveDisplacement[(RegionDisplacement/.FullOptions)];
(* do extension *)
CanvasRegion=ExtendRegion@@FigResolveRegionExtension[CanvasRegion,(RegionExtension/.FullOptions)];
(* return *)
Absolute[CanvasRegion]
];
DeclareFigFallThroughError[AdjustRegion];
(*Region points*)
(*User-level region point extraction*)
RegionPoint[r:FigRegionPattern,Offset:FigOffsetPattern]:=Module[
{UsedOffset,CanvasRegion,CanvasCenter,CanvasRadius},
(* resolve geometry *)
UsedOffset=FigResolveOffset[Offset];
CanvasRegion=FigResolveRegion[r];
CanvasCenter=Mean/@CanvasRegion;
CanvasRadius=-(Subtract@@@CanvasRegion)/2;
(* return offset point *)
Absolute[CanvasCenter+UsedOffset*CanvasRadius]
];
(*Object set bounding box*)
ExtractBoundingBox[Object[n:ObjectNamePattern[FigAnchor]]|(n:ObjectNamePattern[FigAnchor])]:=FigPointBoundingBox[Object[n]@GetPoint[]];
ExtractBoundingBox[Object[n:ObjectNamePattern[FigObject]]|(n:ObjectNamePattern[FigObject])]:=(Object[n]@MakeBoundingBox[]);
ObjectCanvasBox[ObjectList:{(ObjectPattern[FigAnchor]|ObjectNamePattern[FigAnchor]|ObjectPattern[FigObject]|ObjectNamePattern[FigObject])..}]:=Module[
{RegionList,ExtremumLists},
RegionList=(ExtractBoundingBox/@ObjectList);
ExtremumLists=MapThread[List,RegionList,2]; (* {{xminlist,xmaxlist},{yminlist,ymaxlist}} *)
MapAt[Max,MapAt[Min,ExtremumLists,{{1,1},{2,1}}],{{1,2},{2,2}}]
];
(*User-level bounding region function*)
BoundingBox[
ObjectList:{(ObjectPattern[FigAnchor]|ObjectNamePattern[FigAnchor]|ObjectPattern[FigObject]|ObjectNamePattern[FigObject])..}
]:=Module[
{},
FigCheckInFigure[BoundingBox];
Absolute[ObjectCanvasBox[ObjectList]]
];
BoundingBox[
obj:((ObjectPattern[FigAnchor]|ObjectNamePattern[FigAnchor]|ObjectPattern[FigObject]|ObjectNamePattern[FigObject]))
]:=BoundingBox[{obj}];
DeclareFigFallThroughError[BoundingBox];
(*Edge-type parameter list interpretation*)
(*modeled on FrameLabel, etc.*)
(**)
(*general rules*)
(* [B -> {B,B} -- contrary to Mathematica FrameLabel behavior {B,X}]*)
(* This case is usually only reasonable a boolean parameter or a style parameter. *)
(* Pattern: EdgeXYSameParametersPattern[patt]*)
(* Other properties are XY properties, and a value appropriate to X should never propagate to Y, except perhaps the value None.*)
(* Patterns: EdgeXYUniqueParametersPattern[patt]*)
(* It is up to the *pattern* to exclude other possibilities, such as AxisLabel->"x".*)
(* {B,L} -> {{L,X},{B,X}} no mirroring*)
(* or {{L,L},{B,B}} mirroring*)
(* {{L,R},{B,T}} left unchanged*)
(*legacy list format rules*)
(* {B} was legitimate legacy case but is disallowed in present conversion*)
(* {B,L,T} was legitimate legacy case but is disallowed in present conversion*)
(* {B,L,T,R}->{{L,R},{B,T}}*)
(*where X is given filler*)
(**)
(*No special treatment is imposed on the value None. For instance, it is not translated into Filler.*)
(*example usage: *)
(* EdgeParametersPattern[NonListPattern]) -- includes None as allowable case*)
(* None|EdgeParametersPattern[FlatListPattern]*)
(*Masking of edge options*)
(*EdgeMaskingFunction[DataEntry_,MaskEntry_,ExteriorEdgeMaskEntry_,Filler_] masks DataEntry, i.e., returning either DataEntry or Filler. DataEntry is returned if the mask value is True or is Exterior on an exterior edge (as indicated by ExteriorEdgeMaskEntry).*)
EdgeMaskingFunction[DataEntry_,MaskEntry_,ExteriorEdgeMaskEntry_,Filler_]:=If[
(MaskEntry===True)||((MaskEntry===Exterior)&&ExteriorEdgeMaskEntry),
DataEntry,
Filler
];
MaskEdgeOption[
Data:{{_,_},{_,_}},
Mask:{{Exterior|LogicalPattern,Exterior|LogicalPattern},{Exterior|LogicalPattern,Exterior|LogicalPattern}},ExteriorEdgeMask:{{LogicalPattern,LogicalPattern},{LogicalPattern,LogicalPattern}},
Filler_
]:=MapThread[
EdgeMaskingFunction[##,Filler]&,
{Data,Mask,ExteriorEdgeMask},
2
];
(*Automatic values for edge options*)
ResolveAutomaticEdgeOption[
Data:{{_,_},{_,_}},
Defaults:{{_,_},{_,_}}
]:=MapThread[
Replace[#1,{Automatic->#2}]&,
{Data,Defaults},
2
];
ResolveAutomaticEdgeOption[{{1,2},{3,Automatic}},{{5,6},{7,8}}]
(*Single-coordinate geometry*)
(*Single-coordinate pattern*)
FigCoordinatePattern=((_?NumericQ)|(Scaled|Absolute)[(_?NumericQ)]|FigPointPattern);
(*Complementary coordinate index*)
AntiCoordinateIndex[1]=2;
AntiCoordinateIndex[2]=1;
(*Interpret Horizontal/Vertical as coordinate indices*)
FigResolveCoordinateIndex[Horizontal]=1;
FigResolveCoordinateIndex[Vertical]=2;
(*Conversion of coordinate system for individual coordinate*)
(*must come *after* point geometry, since uses FigPointPattern*)
(*can be used eith to convert a single coordinate to canvas coordinates or to extract canvas coordinate from a point*)
(*Conversions*)
FigResolveCoordinate[x_?NumericQ,CoordinateIndex:(1|2)]:=FigResolvePoint[x*UnitVector[CoordinateIndex]][[CoordinateIndex]];
FigResolveCoordinate[Scaled[x_?NumericQ],CoordinateIndex:(1|2)]:=FigResolvePoint[Scaled[x*UnitVector[CoordinateIndex]]][[CoordinateIndex]];
FigResolveCoordinate[Absolute[x_?NumericQ],CoordinateIndex:(1|2)]:=x;
FigResolveCoordinate[p:FigPointPattern,CoordinateIndex:(1|2)]:=FigResolvePoint[p][[CoordinateIndex]];
(*Interpret Horizontal/Vertical as arguments*)
FigResolveCoordinate[x_,Horizontal]:=FigResolveCoordinate[x,1];
FigResolveCoordinate[x_,Vertical]:=FigResolveCoordinate[x,2];
(*Conversion of coordinate system for individual coordinate*)
(*Conversions*)
FigResolveCoordinateDisplacement[x_?NumericQ,CoordinateIndex:(1|2)]:=FigResolveDisplacement[x*UnitVector[CoordinateIndex]][[CoordinateIndex]];
FigResolveCoordinateDisplacement[Scaled[x_?NumericQ],CoordinateIndex:(1|2)]:=FigResolveDisplacement[Scaled[x*UnitVector[CoordinateIndex]]][[CoordinateIndex]];
FigResolveCoordinateDisplacement[Absolute[x_?NumericQ],CoordinateIndex:(1|2)]:=x;
FigResolveCoordinateDisplacement[p:FigPointPattern,CoordinateIndex:(1|2)]:=FigResolveDisplacement[p][[CoordinateIndex]];
(*Interpret Horizontal/Vertical as arguments*)
FigResolveCoordinateDisplacement[x_,Horizontal]:=FigResolveCoordinateDisplacement[x,1];
FigResolveCoordinateDisplacement[x_,Vertical]:=FigResolveCoordinateDisplacement[x,2];
(*Point set geometry*)
(*Point set pattern*)
FigPointSetPattern[n_Integer]:={Repeated[FigPointPattern,{n,Infinity}]};
(*Centroid of point set*)
(*Note: Returns a Canvas point specification, rather than just a canvas coordinate pair. This is so the user can use PointCentroid[] as a point specification.*)
CentroidPoint[PointSet:FigPointSetPattern[1]]:=Absolute[Mean[FigResolvePoint/@PointSet]];
(*Bounding box of point set*)
FigPointSetBoundingBox[PointSet:FigPointSetPattern[1]]:={{Min[First/@PointSet],Max[First/@PointSet]},{Min[Last/@PointSet],Max[Last/@PointSet]}};
(*Rectangle/ellipse geometry*)
(*Radius pattern*)
FigRadiusPattern=NonNegativeIntervalParametersPattern|((Horizontal|Vertical|Absolute|Scaled)[NonNegativeIntervalParametersPattern])|{
((_?NonNegative)|(Scaled|Absolute)[(_?NonNegative)]),
((_?NonNegative)|(Scaled|Absolute)[(_?NonNegative)])
};
(*Geometry calculations*)
(*calculate {CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle} for a rectangle*)
(*this function takes care of point resolution for the arguments but does no option validation*)
(*given center (with option Radius)*)
MakeRectangleGeometry[p:FigPointPattern,FullOptions_List]:=Module[
{Anchor,UsedAnchorOffset,UsedPivotOffset,
CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle},
(* resolve arguments *)
Anchor=FigAnchor[p];
CanvasRadius=FigResolveRadius[(Radius/.FullOptions)];
UsedAnchorOffset=FigResolveOffset[(AnchorOffset/.FullOptions)];
UsedPivotOffset=FigResolveOffset[ResolveOption[PivotOffset,{Automatic->UsedAnchorOffset},FullOptions]];
RotationAngle=UpgradeScalar[ResolveOption[Rotate,{Automatic->AnchorAngle[Anchor]},FullOptions]];
(* derived geometry *)
CanvasCenter=FigResolvePoint[Anchor]-UsedAnchorOffset*CanvasRadius;
CanvasPivot=CanvasCenter+UsedPivotOffset*CanvasRadius;
(* combined answer *)
{CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle}
];
(*given diametric corners*)
MakeRectangleGeometry[p1:FigPointPattern,p2:FigPointPattern,FullOptions_List]:=Module[
{CanvasCorner1,CanvasCorner2,CanvasCenter,CanvasPivot,CanvasRadius,RotationAngle,UsedRoundingRadius},
(* generate geometry *)
CanvasCorner1=FigResolvePoint[p1];
CanvasCorner2=FigResolvePoint[p2];
CanvasCenter=(CanvasCorner2+CanvasCorner1)/2;
CanvasRadius=Abs[(CanvasCorner2-CanvasCorner1)/2]; (* Abs allows any two points to be taken, not just lower left to upper right *)
(* invoke base form *)
MakeRectangleGeometry [
Absolute[CanvasCenter],
Join[{AnchorOffset->Center,Radius->Absolute[CanvasRadius]},FullOptions]
]
];
(*given region specification*)
MakeRectangleGeometry[r:FigRegionPattern,FullOptions_List]:=Module[
{CanvasRegion,CanvasCorner1,CanvasCorner2,CanvasCenter,CanvasPivot,CanvasRadius,RotationAngle,UsedRoundingRadius},
(* generate geometry *)
CanvasRegion=FigResolveRegion[r];
{CanvasCorner1,CanvasCorner2}=Transpose@CanvasRegion;
CanvasCenter=(CanvasCorner2+CanvasCorner1)/2;
CanvasRadius=Abs[(CanvasCorner2-CanvasCorner1)/2]; (* Abs allows any two points to be taken, not just lower left to upper right *)
(* invoke base form *)
MakeRectangleGeometry [
Absolute[CanvasCenter],
Join[{AnchorOffset->Center,Radius->Absolute[CanvasRadius]},FullOptions]
]
];
(*Make region given rectangle specification*)
(*User-level function to convert a rectangle specification to a Canvas region specification*)
(*For rotated rectangle, circumscribing bounding box is used*)
(*TODO option resultion and validation*)
(*RectangleRegion[Args___]:=Canvas[FigRectangleBoundingBox@@MakeRectangleGeometry[Args]];*)
(*Standard rectangle geometry options*)
FigRectangleOptions={
(* geometry *)
Radius->1,AnchorOffset->Center,PivotOffset->Automatic,Rotate->None};
FigCheckRectangleOptions[Self_Object]:=Module[
{},
FigCheckOption[Self,Radius,FigRadiusPattern,FigOptions];
FigCheckOption[Self,AnchorOffset,FigOffsetPattern,FigOptions];
FigCheckOption[Self,PivotOffset,Automatic|FigOffsetPattern,FigOptions];
FigCheckOption[Self,Rotate,Automatic|ScalarParameterPattern,FigOptions];
];
(*FigResolveRadius*)
(*closely related to FigResolveDisplacement:*)
(* -- upgrades single radius argument*)
(* -- allows for "vertical" or "horizontal" units*)
(* -- requires nonnegative arguments*)
(*User coordinates: None or r or {rx,ry}*)
FigResolveRadius[r:NonNegativeIntervalParametersPattern]:=(CurrentWindow[]@DeltaTFunction[])@UpgradePairEqual[r];
(*Horizontal user coordinates: Horizontal[None] or Horizontal[r] or Horizontal[{rx,ry}]*)
FigResolveRadius[Horizontal[r:NonNegativeIntervalParametersPattern]]:=Module[
{LengthUnit},
LengthUnit=First[(CurrentWindow[]@DeltaTFunction[])@{1,0}];
LengthUnit*UpgradePairEqual[r]
];
(*Vertical user coordinates: Vertical[None] or Vertical[r] or Vertical[{rx,ry}]*)
FigResolveRadius[Vertical[r:NonNegativeIntervalParametersPattern]]:=Module[
{LengthUnit},
LengthUnit=Last[(CurrentWindow[]@DeltaTFunction[])@{0,1}];
LengthUnit*UpgradePairEqual[r]
];
(*Canvas coordinates: Canvas[None] or Canvas[r] or Canvas[{rx,ry}]*)
FigResolveRadius[Absolute[r:NonNegativeIntervalParametersPattern]]:=UpgradePairEqual[r];
(*Scaled coordinates: Scaled[None] or Scaled[r] or Scaled[{rx,ry}]*)
FigResolveRadius[Scaled[r:NonNegativeIntervalParametersPattern]]:=(CurrentWindow[]@ScaledDeltaTFunction[])@UpgradePairEqual[r];
(*Ad hoc treatment of hybrid coordinates*)
FigResolveRadius[
p:Except[
{_?NumericQ,_?NumericQ},
{
x:((_?NonNegative)|(Scaled|Absolute)[(_?NonNegative)]),
y:((_?NonNegative)|(Scaled|Absolute)[(_?NonNegative)])
}
]
]:=FigResolveDisplacement[p];
(*Rectangle "circumference" points*)
(*used also for circle geometry*)
RectangleOffsetPoint[CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,Offset:{_?NumericQ,_?NumericQ}]:=RotationTransform[RotationAngle,CanvasPivot]@(CanvasCenter+CanvasRadius*Offset);
(*segments orientations are in the "upward" and "rightward" directions (with respect to the original unrotated rectangle)*)
RectangleSideSegment[CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,Side:Left]:={
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,{-1,-1}],
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,{-1,+1}]
};
RectangleSideSegment[CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,Side:Right]:={
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,{+1,-1}],
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,{+1,+1}]
};
RectangleSideSegment[CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,Side:Bottom]:={
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,{-1,-1}],
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,{+1,-1}]
};
RectangleSideSegment[CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,Side:Top]:={
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,{-1,+1}],
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,{+1,+1}]
};
(*Rectangle anchors*)
(*A "rectangle" here more generally means a tilted rectangle*)
(*Named points: Center (default), Left/Right, Bottom/Top*)
(* identical to circle, sans AngleRange parameter*)
FigRectangleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
Name:NamedPointPattern,
Arg:None
]:=FigAnchor[Absolute[RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,NamedPointOffset[Name]]],-NamedPointOffset[Name],RotationAngle];
FigRectangleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
Name:Offset,
OffsetValue:FigOffsetPattern
]:=FigAnchor[Absolute[RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,FigResolveOffset[OffsetValue]]],{0,0},RotationAngle];
(*Side interpolations: {Left|Right|Bottom|Top,x}*)
(*Note: Simple side points could be absorbed as special case by making x default to 0 but are already handled as named points above.*)
(*Reference:(Tail|Center|Head):Center,Mode:(Absolute|Scaled):Scaled*)
FigRectangleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
Name:(Left|Right|Bottom|Top),
x_?NumericQ
]:=FigAnchor[
Absolute[
InterpolateSegment[
RectangleSideSegment[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,Name],
Center,Scaled,x
]
],
-NamedPointOffset[Name],
RotationAngle
];
(*Rectangle bounding box*)
FigRectangleBoundingBox[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ
]:=FigPointSetBoundingBox[Table[
RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,Offset],
{Offset,{{-1,-1},{-1,+1},{+1,-1},{+1,+1}}}
]
];
(*Circle anchors*)
(*A "circle" here more generally means a tilted ellipse*)
(*Named points: Center (default), Left/Right, Bottom/Top*)
FigCircleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},AngleRange:{theta1_?NumericQ,theta2_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
Name:(Center|Left|Right|Bottom|Top),
Arg:None
]:=FigAnchor[Absolute[RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,NamedPointOffset[Name]]],-NamedPointOffset[Name],RotationAngle];
FigCircleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},AngleRange:{theta1_?NumericQ,theta2_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
Name:Offset,
OffsetValue:FigOffsetPattern
]:=FigAnchor[Absolute[RectangleOffsetPoint[CanvasCenter,CanvasRadius,CanvasPivot,RotationAngle,FigResolveOffset[OffsetValue]]],{0,0},RotationAngle];
(*For a circle, the conventional direction is the "positive theta" direction from polar coordinates, i.e., CCW. For instance, this is the convention followed by the ordering of the arc angle arguments {theta1,theta2} in the Mathematica Circle and Disk primatives. However, it is more natural for the text baseline to follow the "negative theta" tangent, so that the text "sits on" the outside of the circle. This is the convention adopted with the anchors for Point, for instance. For the most part, TextRectify renders this problem irrelevant. However, the orientation of the tangent also affect arrowheads. *)
(*Curve anchors:*)
(* Normal/Tangent, t|Scaled[t]*)
(*Previously: FigCircle sorted the AngleRange angles to *enforce* a CCW curve. The solution was to use the "negative theta" tangent, but still have the scaled curve parameter run from 0=Tail to 1=Head going CCW, and then flip the tangent used in drawing arrowheads (with RotateAnchor[Self@MakeAnchor[Tail,None],Pi],RotateAnchor[Self@MakeAnchor[Head,None],Pi]).*)
(*FigCircleAnchor[*)
(* CanvasCenter : {_?NumericQ, _?NumericQ}, CanvasRadius : {_?NumericQ, _?NumericQ}, AngleRange : {theta1_?NumericQ, theta2_?NumericQ}, CanvasPivot : {_?NumericQ, _?NumericQ}, RotationAngle_?NumericQ,*)
(* OrthoMode : (Normal | Tangent), Arg : ((t_?NumericQ) | Scaled[t_?NumericQ])*)
(* ] := Module[*)
(* {theta, AnchorPoint, TangentAngle, AnchorAngle, AnchorOffset},*)
(* *)
(* theta = Switch[*)
(* Arg,*)
(* _?NumericQ, t, (* literal angle, before rotation *)*)
(* Scaled[_?NumericQ], RescaleInterval[{0, 1}, {theta1, theta2}][t] (* scaled from 0 to 1 on displayed arc *)*)
(* ];*)
(* AnchorPoint = RotationTransform[RotationAngle, CanvasPivot]@(CanvasCenter + CanvasRadius*{Cos[theta], Sin[theta]});*)
(* AnchorOffset = Switch[OrthoMode, Normal, {-1, 0}, Tangent, {0, -1}];*)
(* TangentAngle = VectorArcTan[CanvasRadius*{Sin[theta], -Cos[theta]}] + RotationAngle; (* tangent vector in negative theta sense *)*)
(* AnchorAngle = TangentAngle + Switch[OrthoMode, Normal, +Pi/2, Tangent, 0];*)
(* *)
(* FigAnchor[Canvas[AnchorPoint], AnchorOffset, AnchorAngle]*)
(* ];*)
(*Revised: FigCircle leaves the angles unsorted, so curve sense can be either way. The d(theta) for the tangent is in the same sense as the delta(theta) of the angles. The scaled curve parameter runs from 0=Tail to 1=Head.*)
FigCircleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},AngleRange:{theta1_?NumericQ,theta2_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
OrthoMode:(Normal|Tangent),
Arg:((t_?NumericQ)|{"Angle",t_?NumericQ})
]:=Module[
{theta,AnchorPoint,TangentAngle,AnchorAngle,AnchorOffset,ArcSense},
(* arc sense: +1 for CCW or -1 for CW *)
ArcSense=Sign[theta2-theta1];
theta=Switch[
Arg,
{"Angle",_?NumericQ},t, (* literal angle, before rotation *)
_?NumericQ,RescaleInterval[{0,1},{theta1,theta2}][t] (* scaled from 0 to 1 on displayed arc *)
];
AnchorPoint=RotationTransform[RotationAngle,CanvasPivot]@(CanvasCenter+CanvasRadius*{Cos[theta],Sin[theta]});
AnchorOffset=Switch[OrthoMode,Normal,{1,0},Tangent,{0,1}]*ArcSense;
(* trig gives tangent vector in negative theta sense -- for arc tangent, this must be flipped if delta theta is positive; for outward normal, this must have Pi/2 added *)
TangentAngle=VectorArcTan[CanvasRadius*{Sin[theta],-Cos[theta]}]+RotationAngle;
(* trig gives tangent vector in negative theta sense, which y *)
AnchorAngle=TangentAngle+Switch[OrthoMode,Normal,+Pi/2,Tangent,Switch[ArcSense,+1,Pi,-1|0,0]];
FigAnchor[Absolute[AnchorPoint],AnchorOffset,AnchorAngle]
];
FigCircleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},AngleRange:{theta1_?NumericQ,theta2_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
OrthoMode:(Normal|Tangent),
Arg:None]:=FigCircleAnchor[CanvasCenter,CanvasRadius,AngleRange,CanvasPivot,RotationAngle,
OrthoMode,0.5
];
(*Head/Tail anchors -- tangent at endpoint of arc*)
FigCircleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},AngleRange:{theta1_?NumericQ,theta2_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
Name:Tail,
Arg:None
]:=FigCircleAnchor[CanvasCenter,CanvasRadius,AngleRange,CanvasPivot,RotationAngle,Tangent,0];
FigCircleAnchor[
CanvasCenter:{_?NumericQ,_?NumericQ},CanvasRadius:{_?NumericQ,_?NumericQ},AngleRange:{theta1_?NumericQ,theta2_?NumericQ},CanvasPivot:{_?NumericQ,_?NumericQ},RotationAngle_?NumericQ,
Name:Head,