@@ -43,25 +43,60 @@ class Box(BaseParam):
4343 ... clearance=0.2,
4444 ... pen="blue",
4545 ... radius="10p",
46- ... shading=("5p", "5p", "lightred"),
46+ ... shading_offset=("5p", "5p"),
47+ ... shading_fill="lightred",
4748 ... )
4849 ... )
4950 '+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"))
5152 '+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'
5255 """
5356
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+ """
5467 clearance : float | str | Sequence [float | str ] | None = None
5568 fill : str | None = None
56- innerborder : str | Sequence | None = None
69+ inner_gap : float | str | None = None
70+ inner_pen : str | None = None
5771 pen : str | None = None
5872 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
6095
6196 _aliases : ClassVar = [
6297 Alias ("clearance" , prefix = "+c" , separator = "/" ),
6398 Alias ("fill" , prefix = "+g" ),
64- Alias ("innerborder" , prefix = "+i" , separator = "/" ),
99+ Alias ("innerborder" , prefix = "+i" ),
65100 Alias ("pen" , prefix = "+p" ),
66101 Alias ("radius" , prefix = "+r" ),
67102 Alias ("shading" , prefix = "+s" , separator = "/" ),
0 commit comments