@@ -380,7 +380,7 @@ def convert_effects(fig_node: dict) -> _Effects:
380
380
)
381
381
)
382
382
383
- elif e ["type" ] == "FOREGROUND_BLUR" :
383
+ elif e ["type" ] == "FOREGROUND_BLUR" or e [ "type" ] == "BACKGROUND_BLUR" :
384
384
if (
385
385
len (sketch ["blurs" ])
386
386
and hasattr (sketch ["blurs" ][0 ], "isEnabled" )
@@ -389,26 +389,39 @@ def convert_effects(fig_node: dict) -> _Effects:
389
389
utils .log_conversion_warning ("STY001" , fig_node )
390
390
continue
391
391
392
- sketch ["blurs" ].append (
393
- Blur (
394
- radius = e ["radius" ] / 2 , # Looks best dividing by 2, no idea why,
395
- type = BlurType .GAUSSIAN ,
396
- )
392
+ blur_type = (
393
+ BlurType .GAUSSIAN if e ["type" ] == "FOREGROUND_BLUR" else BlurType .BACKGROUND
397
394
)
398
-
399
- elif e ["type" ] == "BACKGROUND_BLUR" :
400
- if (
401
- len (sketch ["blurs" ])
402
- and hasattr (sketch ["blurs" ][0 ], "isEnabled" )
403
- and sketch ["blurs" ][0 ].isEnabled
404
- ):
405
- utils .log_conversion_warning ("STY001" , fig_node )
406
- continue
395
+ blur_radius = e ["radius" ] / 2 # Looks best dividing by 2
396
+ is_progressive = "blurOpType" in e .keys () and e ["blurOpType" ] == "PROGRESSIVE"
397
+ progressive_blur_start = e .get ("startOffset" , {"x" : 0 , "y" : 0 })
398
+ progressive_blur_end = e .get ("endOffset" , {"x" : 0 , "y" : 0 })
399
+ progressive_start_radius = (e .get ("startRadius" , 0 ) / 2 ) / blur_radius
407
400
408
401
sketch ["blurs" ].append (
409
402
Blur (
410
- radius = e ["radius" ] / 2 , # Looks best dividing by 2, no idea why,
411
- type = BlurType .BACKGROUND ,
403
+ radius = blur_radius ,
404
+ type = blur_type ,
405
+ isProgressive = is_progressive ,
406
+ gradient = (
407
+ Gradient (
408
+ from_ = Point (progressive_blur_start ["x" ], progressive_blur_start ["y" ]),
409
+ to = Point (progressive_blur_end ["x" ], progressive_blur_end ["y" ]),
410
+ stops = [
411
+ GradientStop (
412
+ color = Color (
413
+ red = 0 , green = 0 , blue = 0 , alpha = progressive_start_radius
414
+ ),
415
+ position = 0 ,
416
+ ),
417
+ GradientStop (
418
+ color = Color (red = 0 , green = 0 , blue = 0 , alpha = 1 ), position = 1
419
+ ),
420
+ ],
421
+ )
422
+ if is_progressive
423
+ else None
424
+ ),
412
425
)
413
426
)
414
427
0 commit comments