Private
Public Access
some organization pass, still need to review a bunch
This commit is contained in:
+6
-9
@@ -3,13 +3,12 @@ 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.
|
||||
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
|
||||
steps = int(shadow_size)
|
||||
if steps <= 0: return
|
||||
|
||||
alpha_step = a / steps
|
||||
|
||||
@@ -17,12 +16,10 @@ def draw_soft_shadow(draw_list: imgui.ImDrawList, p_min: imgui.ImVec2, p_max: im
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
@@ -35,4 +32,4 @@ def draw_soft_shadow(draw_list: imgui.ImDrawList, p_min: imgui.ImVec2, p_max: im
|
||||
rounding + expand if rounding > 0 else 0.0,
|
||||
flags=imgui.ImDrawFlags_.round_corners_all if rounding > 0 else imgui.ImDrawFlags_.none,
|
||||
thickness=1.0
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user