@@ -202,40 +202,32 @@ export const parseBoundCurves = (
202
202
borders : Array < Border > ,
203
203
borderRadius : Array < BorderRadius >
204
204
) : BoundCurves => {
205
- const HALF_WIDTH = bounds . width / 2 ;
206
- const HALF_HEIGHT = bounds . height / 2 ;
207
- const tlh =
208
- borderRadius [ CORNER . TOP_LEFT ] [ H ] . getAbsoluteValue ( bounds . width ) < HALF_WIDTH
209
- ? borderRadius [ CORNER . TOP_LEFT ] [ H ] . getAbsoluteValue ( bounds . width )
210
- : HALF_WIDTH ;
211
- const tlv =
212
- borderRadius [ CORNER . TOP_LEFT ] [ V ] . getAbsoluteValue ( bounds . height ) < HALF_HEIGHT
213
- ? borderRadius [ CORNER . TOP_LEFT ] [ V ] . getAbsoluteValue ( bounds . height )
214
- : HALF_HEIGHT ;
215
- const trh =
216
- borderRadius [ CORNER . TOP_RIGHT ] [ H ] . getAbsoluteValue ( bounds . width ) < HALF_WIDTH
217
- ? borderRadius [ CORNER . TOP_RIGHT ] [ H ] . getAbsoluteValue ( bounds . width )
218
- : HALF_WIDTH ;
219
- const trv =
220
- borderRadius [ CORNER . TOP_RIGHT ] [ V ] . getAbsoluteValue ( bounds . height ) < HALF_HEIGHT
221
- ? borderRadius [ CORNER . TOP_RIGHT ] [ V ] . getAbsoluteValue ( bounds . height )
222
- : HALF_HEIGHT ;
223
- const brh =
224
- borderRadius [ CORNER . BOTTOM_RIGHT ] [ H ] . getAbsoluteValue ( bounds . width ) < HALF_WIDTH
225
- ? borderRadius [ CORNER . BOTTOM_RIGHT ] [ H ] . getAbsoluteValue ( bounds . width )
226
- : HALF_WIDTH ;
227
- const brv =
228
- borderRadius [ CORNER . BOTTOM_RIGHT ] [ V ] . getAbsoluteValue ( bounds . height ) < HALF_HEIGHT
229
- ? borderRadius [ CORNER . BOTTOM_RIGHT ] [ V ] . getAbsoluteValue ( bounds . height )
230
- : HALF_HEIGHT ;
231
- const blh =
232
- borderRadius [ CORNER . BOTTOM_LEFT ] [ H ] . getAbsoluteValue ( bounds . width ) < HALF_WIDTH
233
- ? borderRadius [ CORNER . BOTTOM_LEFT ] [ H ] . getAbsoluteValue ( bounds . width )
234
- : HALF_WIDTH ;
235
- const blv =
236
- borderRadius [ CORNER . BOTTOM_LEFT ] [ V ] . getAbsoluteValue ( bounds . height ) < HALF_HEIGHT
237
- ? borderRadius [ CORNER . BOTTOM_LEFT ] [ V ] . getAbsoluteValue ( bounds . height )
238
- : HALF_HEIGHT ;
205
+ let tlh = borderRadius [ CORNER . TOP_LEFT ] [ H ] . getAbsoluteValue ( bounds . width ) ;
206
+ let tlv = borderRadius [ CORNER . TOP_LEFT ] [ V ] . getAbsoluteValue ( bounds . height ) ;
207
+ let trh = borderRadius [ CORNER . TOP_RIGHT ] [ H ] . getAbsoluteValue ( bounds . width ) ;
208
+ let trv = borderRadius [ CORNER . TOP_RIGHT ] [ V ] . getAbsoluteValue ( bounds . height ) ;
209
+ let brh = borderRadius [ CORNER . BOTTOM_RIGHT ] [ H ] . getAbsoluteValue ( bounds . width ) ;
210
+ let brv = borderRadius [ CORNER . BOTTOM_RIGHT ] [ V ] . getAbsoluteValue ( bounds . height ) ;
211
+ let blh = borderRadius [ CORNER . BOTTOM_LEFT ] [ H ] . getAbsoluteValue ( bounds . width ) ;
212
+ let blv = borderRadius [ CORNER . BOTTOM_LEFT ] [ V ] . getAbsoluteValue ( bounds . height ) ;
213
+
214
+ const factors = [ ] ;
215
+ factors . push ( ( tlh + trh ) / bounds . width ) ;
216
+ factors . push ( ( blh + brh ) / bounds . width ) ;
217
+ factors . push ( ( tlv + blv ) / bounds . height ) ;
218
+ factors . push ( ( trv + brv ) / bounds . height ) ;
219
+ const maxFactor = Math . max ( ...factors ) ;
220
+
221
+ if ( maxFactor > 1 ) {
222
+ tlh /= maxFactor ;
223
+ tlv /= maxFactor ;
224
+ trh /= maxFactor ;
225
+ trv /= maxFactor ;
226
+ brh /= maxFactor ;
227
+ brv /= maxFactor ;
228
+ blh /= maxFactor ;
229
+ blv /= maxFactor ;
230
+ }
239
231
240
232
const topWidth = bounds . width - trh ;
241
233
const rightHeight = bounds . height - brv ;
0 commit comments