@@ -380,7 +380,7 @@ def convert_effects(fig_node: dict) -> _Effects:
380380 )
381381 )
382382
383- elif e ["type" ] == "FOREGROUND_BLUR" :
383+ elif e ["type" ] == "FOREGROUND_BLUR" or e [ "type" ] == "BACKGROUND_BLUR" :
384384 if (
385385 len (sketch ["blurs" ])
386386 and hasattr (sketch ["blurs" ][0 ], "isEnabled" )
@@ -389,26 +389,39 @@ def convert_effects(fig_node: dict) -> _Effects:
389389 utils .log_conversion_warning ("STY001" , fig_node )
390390 continue
391391
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
397394 )
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
407400
408401 sketch ["blurs" ].append (
409402 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+ ),
412425 )
413426 )
414427
0 commit comments