@@ -107,6 +107,79 @@ def getSuperRoundedRectPath(rect: QRectF,
107107 return _cachedGetSuperRoundedRectPath (rect_tuple , radius_x , radius_y , power , quality )
108108
109109
110+ def getRoundedRectPathQuad (rect : QRectF ,
111+ radius_tl : float , radius_tr : float ,
112+ radius_br : float , radius_bl : float ) -> QPainterPath :
113+ """
114+ 使用 quadTo 绘制不对称圆角矩形
115+ :param rect: QRectF 矩形区域
116+ :param radius_tl: 左上角半径
117+ :param radius_tr: 右上角半径
118+ :param radius_br: 右下角半径
119+ :param radius_bl: 左下角半径
120+ """
121+ path = QPainterPath ()
122+
123+ # 左上角开始
124+ path .moveTo (rect .left () + radius_tl , rect .top ())
125+ path .lineTo (rect .right () - radius_tr , rect .top ())
126+ if radius_tr > 0 :
127+ path .quadTo (rect .right (), rect .top (), rect .right (), rect .top () + radius_tr )
128+ else :
129+ path .lineTo (rect .right (), rect .top ())
130+
131+ path .lineTo (rect .right (), rect .bottom () - radius_br )
132+ if radius_br > 0 :
133+ path .quadTo (rect .right (), rect .bottom (), rect .right () - radius_br , rect .bottom ())
134+ else :
135+ path .lineTo (rect .right (), rect .bottom ())
136+
137+ path .lineTo (rect .left () + radius_bl , rect .bottom ())
138+ if radius_bl > 0 :
139+ path .quadTo (rect .left (), rect .bottom (), rect .left (), rect .bottom () - radius_bl )
140+ else :
141+ path .lineTo (rect .left (), rect .bottom ())
142+
143+ path .lineTo (rect .left (), rect .top () + radius_tl )
144+ if radius_tl > 0 :
145+ path .quadTo (rect .left (), rect .top (), rect .left () + radius_tl , rect .top ())
146+ else :
147+ path .lineTo (rect .left (), rect .top ())
148+
149+ path .closeSubpath ()
150+ return path
151+
152+
153+ def getRoundedRectPathArc (rect : QRectF ,
154+ radius_tl : float , radius_tr : float ,
155+ radius_br : float , radius_bl : float ) -> QPainterPath :
156+ """
157+ 使用 arcTo 绘制不对称圆角矩形
158+ :param rect: QRectF 矩形区域
159+ :param radius_tl: 左上角半径
160+ :param radius_tr: 右上角半径
161+ :param radius_br: 右下角半径
162+ :param radius_bl: 左下角半径
163+ """
164+ path = QPainterPath ()
165+
166+ path .moveTo (rect .left () + radius_tl , rect .top ())
167+
168+ path .lineTo (rect .right () - radius_tr , rect .top ())
169+ path .arcTo (QRectF (rect .right () - 2 * radius_tr , rect .top (), 2 * radius_tr , 2 * radius_tr ), 90 , - 90 )
170+
171+ path .lineTo (rect .right (), rect .bottom () - radius_br )
172+ path .arcTo (QRectF (rect .right () - 2 * radius_br , rect .bottom () - 2 * radius_br , 2 * radius_br , 2 * radius_br ), 0 , - 90 )
173+
174+ path .lineTo (rect .left () + radius_bl , rect .bottom ())
175+ path .arcTo (QRectF (rect .left (), rect .bottom () - 2 * radius_bl , 2 * radius_bl , 2 * radius_bl ), 270 , - 90 )
176+
177+ path .lineTo (rect .left (), rect .top () + radius_tl )
178+ path .arcTo (QRectF (rect .left (), rect .top (), 2 * radius_tl , 2 * radius_tl ), 180 , - 90 )
179+
180+ path .closeSubpath ()
181+ return path
182+
110183@lru_cache (maxsize = None )
111184def _cachedGaussianLinearGradient (start_x , start_y , final_stop_x , final_stop_y , color_code , quality ):
112185
0 commit comments