from imgui_bundle import imgui


def draw_soft_shadow(draw_list: imgui.ImDrawList, p_min: imgui.ImVec2, p_max: imgui.ImVec2, color: imgui.ImVec4, shadow_size: float = 10.0, rounding: float = 0.0) -> None:
 """
 Simulates a soft shadow effect by drawing multiple concentric rounded rectangles
 with decreasing alpha values. This is a faux-shader effect using primitive batching.
 """
 r, g, b, a = color.x, color.y, color.z, color.w
 steps      = int(shadow_size)
 if steps <= 0: return
  
 alpha_step = a / steps
 
 for i in range(steps):
  current_alpha = a - (i * alpha_step)
  # Apply an easing function (e.g., cubic) for a smoother shadow falloff
  current_alpha = current_alpha * (1.0 - (i / steps)**2) 
  if current_alpha <= 0.01:
   continue
  
  expand = float(i)
  c_min = imgui.ImVec2(p_min.x - expand, p_min.y - expand)
  c_max = imgui.ImVec2(p_max.x + expand, p_max.y + expand)
  
  u32_color = imgui.get_color_u32(imgui.ImVec4(r, g, b, current_alpha))
  
  draw_list.add_rect(
   c_min, 
   c_max, 
   u32_color, 
   rounding + expand if rounding > 0 else 0.0, 
   flags=imgui.ImDrawFlags_.round_corners_all if rounding > 0 else imgui.ImDrawFlags_.none,
   thickness=1.0
  )
