@@ -43,25 +43,60 @@ class Box(BaseParam):
43
43
... clearance=0.2,
44
44
... pen="blue",
45
45
... radius="10p",
46
- ... shading=("5p", "5p", "lightred"),
46
+ ... shading_offset=("5p", "5p"),
47
+ ... shading_fill="lightred",
47
48
... )
48
49
... )
49
50
'+c0.2+pblue+r10p+s5p/5p/lightred'
50
- >>> str(Box(clearance=0.2, innerborder=( "2p", "1p,red") , pen="blue"))
51
+ >>> str(Box(clearance=0.2, inner_gap= "2p", inner_pen= "1p,red", pen="blue"))
51
52
'+c0.2+i2p/1p,red+pblue'
53
+ >>> str(Box(clearance=0.2, shading_offset=("5p", "5p"), shading_fill="lightred"))
54
+ '+c0.2+s5p/5p/lightred'
52
55
"""
53
56
57
+ """
58
+ The GMT syntax:
59
+
60
+ [+c<clearance(s)>]
61
+ [+g<fill>]
62
+ [+i[[<gap>/]<pen>]]
63
+ [+p[<pen>]]
64
+ [+r[<radius>]]
65
+ [+s[<dx>/<dy>/][<fill>]]
66
+ """
54
67
clearance : float | str | Sequence [float | str ] | None = None
55
68
fill : str | None = None
56
- innerborder : str | Sequence | None = None
69
+ inner_gap : float | str | None = None
70
+ inner_pen : str | None = None
57
71
pen : str | None = None
58
72
radius : float | bool | None = False
59
- shading : str | Sequence | None = None
73
+ shading_offset : Sequence [float | str ] | None = None
74
+ shading_fill : str | None = None
75
+
76
+ @property
77
+ def innerborder (self ) -> str | None :
78
+ """
79
+ innerborder="{inner_gap}/{inner_pen}"
80
+ """
81
+ args = [self .inner_gap , self .inner_pen ]
82
+ return "/" .join ([v for v in args if v is not None ]) or None
83
+
84
+ @property
85
+ def shading (self ) -> str | None :
86
+ """
87
+ shading="{shading_offset}/{shading_fill}"
88
+ """
89
+ args = (
90
+ [* self .shading_offset , self .shading_fill ]
91
+ if self .shading_offset
92
+ else [self .shading_fill ]
93
+ )
94
+ return "/" .join ([v for v in args if v is not None ]) or None
60
95
61
96
_aliases : ClassVar = [
62
97
Alias ("clearance" , prefix = "+c" , separator = "/" ),
63
98
Alias ("fill" , prefix = "+g" ),
64
- Alias ("innerborder" , prefix = "+i" , separator = "/" ),
99
+ Alias ("innerborder" , prefix = "+i" ),
65
100
Alias ("pen" , prefix = "+p" ),
66
101
Alias ("radius" , prefix = "+r" ),
67
102
Alias ("shading" , prefix = "+s" , separator = "/" ),
0 commit comments