Overview

ShadowEffectLib creates drop shadow effects for visual controls, wrapping the FireMonkey TShadowEffect component. Shadows add depth and visual hierarchy to UI elements — configurable with distance, direction, softness, opacity, and color for professional-quality results.

PropertyDetails
LibraryShadowEffectLib
Prefixshadow_
WrapsTShadowEffect
Functions20
TypeVisual effect (decorative)
CategoryCountDescription
Creation / Destruction2Create and free effect
Distance2Get/set shadow offset
Direction2Get/set light angle
Softness2Get/set blur amount
Opacity2Get/set transparency
Color2Get/set shadow color
Effect Control4Enabled and trigger get/set
Error Handling4Error codes and messages
👁 Depth & Hierarchy: Drop shadows are one of the most fundamental UI design tools. They suggest elevation — a control with a shadow appears to "float" above the background, drawing the user's attention and creating a clear visual hierarchy.

Cross-Platform Support

PlatformSupport
Windows✅ Full support
Linux✅ Full support
Android✅ Full support

Creation & Destruction

shadow#(parent#)

Creates a new shadow effect attached to the specified visual control.

ParameterTypeDescription
parent#PointerTarget visual control
ReturnsPointerEffect handle, or 0 on failure

shadow_free(effect#)

Destroys the effect and releases associated resources.

Error Handling

FunctionSignatureDescription
shadow_error()shadow_error@Returns last error code (0 = none)
shadow_errormsg$()shadow_errormsg$@Returns last error message
shadow_strerror$(code)shadow_strerror$@nConverts error code to text
shadow_clearerror()shadow_clearerror@Clears the error state

Distance

Controls the offset of the shadow from the control in pixels. Larger distance = element appears higher above the surface.

FunctionSignatureDescription
shadow_distance#(effect#, value)shadow_distance#@#nSet offset (0–50 pixels)
shadow_distance(effect#)shadow_distance@#Get distance
ValueAppearanceUse Case
1–3Subtle, close shadowCards, subtle elevation
4–8Medium elevationButtons, dialogs
10–20High floatingPopups, modals
25–50Very dramaticArtistic/dramatic effects

Direction

Sets the angle of the light source in degrees (0–360). The shadow appears on the opposite side of the light.

FunctionSignatureDescription
shadow_direction#(effect#, degrees)shadow_direction#@#nSet light angle (0–360)
shadow_direction(effect#)shadow_direction@#Get direction
AngleLight PositionShadow Falls
45Top-right (default)Bottom-left
90TopBottom
135Top-leftBottom-right
180LeftRight
225Bottom-leftTop-right
270BottomTop
315Bottom-rightTop-left

Softness

Controls the blur amount of the shadow. Higher values create softer, more diffuse shadows.

FunctionSignatureDescription
shadow_softness#(effect#, value)shadow_softness#@#nSet blur (0–1)
shadow_softness(effect#)shadow_softness@#Get softness

Opacity

Controls the transparency of the shadow. Lower values create more subtle shadows.

FunctionSignatureDescription
shadow_opacity#(effect#, value)shadow_opacity#@#nSet opacity (0–1)
shadow_opacity(effect#)shadow_opacity@#Get opacity

Color

Sets the color of the shadow. Defaults to black, but colored shadows can create interesting effects.

FunctionSignatureDescription
shadow_color#(effect#, color$)shadow_color#@#$Set shadow color (name or hex)
shadow_color(effect#)shadow_color@#Get color as number

Effect Control

FunctionSignatureDescription
shadow_enabled#(effect#, value)shadow_enabled#@#nEnable (1) or disable (0)
shadow_enabled(effect#)shadow_enabled@#Gets enabled state
shadow_trigger#(effect#, trigger$)shadow_trigger#@#$Sets trigger string
shadow_trigger$(effect#)shadow_trigger$@#Gets trigger string

Complete Examples

Example 1: Basic Shadow

╯ basic-shadow.bas
let frm# = Pointer#(0)
let rect# = Pointer#(0)
let sh# = Pointer#(0)

frm# = form#("Shadow Demo", 400, 300)

rect# = rectangle#(frm#)
rectangle_bounds#(rect#, 100, 80, 200, 120)
rectangle_fill#(rect#, "White")

sh# = shadow#(rect#)
shadow_distance#(sh#, 5)
shadow_direction#(sh#, 45)
shadow_softness#(sh#, 0.4)
shadow_opacity#(sh#, 0.5)

form_show(frm#)

Example 2: Adjustable Distance

╯ shadow-distance.bas
let frm# = Pointer#(0)
let rect# = Pointer#(0)
let sh# = Pointer#(0)
let lbl# = Pointer#(0)

frm# = form#("Shadow Controls", 450, 320)

rect# = rectangle#(frm#)
rectangle_bounds#(rect#, 125, 40, 200, 100)
rectangle_fill#(rect#, "SteelBlue")

sh# = shadow#(rect#)
shadow_distance#(sh#, 5)
shadow_softness#(sh#, 0.3)

lbl# = label#(frm#, "Distance: 5", 175, 160)

let btn1# = button#(frm#, "Near")
button_bounds#(btn1#, 60, 200, 100, 30)
button_onclick#(btn1#, "SetNear")

let btn2# = button#(frm#, "Medium")
button_bounds#(btn2#, 170, 200, 100, 30)
button_onclick#(btn2#, "SetMedium")

let btn3# = button#(frm#, "Far")
button_bounds#(btn3#, 280, 200, 100, 30)
button_onclick#(btn3#, "SetFar")

form_show(frm#)

function SetNear(sender#)
  shadow_distance#(sh#, 3)
  shadow_softness#(sh#, 0.2)
  label_text#(lbl#, "Distance: 3")
endfunction

function SetMedium(sender#)
  shadow_distance#(sh#, 8)
  shadow_softness#(sh#, 0.4)
  label_text#(lbl#, "Distance: 8")
endfunction

function SetFar(sender#)
  shadow_distance#(sh#, 15)
  shadow_softness#(sh#, 0.6)
  label_text#(lbl#, "Distance: 15")
endfunction

Example 3: Shadow Directions

╯ shadow-directions.bas
let frm# = Pointer#(0)
let rect1# = Pointer#(0)
let rect2# = Pointer#(0)
let sh1# = Pointer#(0)
let sh2# = Pointer#(0)

frm# = form#("Shadow Directions", 450, 250)

' Top-right light (raised look)
rect1# = rectangle#(frm#)
rectangle_bounds#(rect1#, 50, 70, 150, 100)
rectangle_fill#(rect1#, "White")
sh1# = shadow#(rect1#)
shadow_distance#(sh1#, 8)
shadow_direction#(sh1#, 45)
shadow_softness#(sh1#, 0.4)
let lbl1# = label#(frm#, "45 deg (SE)", 80, 180)

' Bottom-left light
rect2# = rectangle#(frm#)
rectangle_bounds#(rect2#, 250, 70, 150, 100)
rectangle_fill#(rect2#, "White")
sh2# = shadow#(rect2#)
shadow_distance#(sh2#, 8)
shadow_direction#(sh2#, 225)
shadow_softness#(sh2#, 0.4)
let lbl2# = label#(frm#, "225 deg (NW)", 275, 180)

form_show(frm#)

Best Practices

PracticeWhy
Use consistent direction across UIA single light source direction looks natural
Increase softness with distanceFarther shadows are softer in real life
Keep opacity moderate (0.3–0.6)Overly dark shadows look harsh
Match shadow to elevation levelCards: 3–5px, Buttons: 2–4px, Modals: 10–20px
Use GlowEffect for interactive controlsShadow effects may block mouse events on the parent
⚠ Mouse Events: Shadow effects may block mouse events on the parent control. For interactive controls (buttons, etc.), consider using GlowEffectLib instead, or apply the shadow to a non-interactive backing shape.

Quick Reference

FunctionSignatureDescription
CREATION & DESTRUCTION
shadow#(parent#)shadow#@#Create effect
shadow_free(effect#)shadow_free@#Destroy effect
DISTANCE
shadow_distance#(effect#, value)shadow_distance#@#nSet offset (0–50 px)
shadow_distance(effect#)shadow_distance@#Get distance
DIRECTION
shadow_direction#(effect#, degrees)shadow_direction#@#nSet light angle (0–360)
shadow_direction(effect#)shadow_direction@#Get direction
SOFTNESS
shadow_softness#(effect#, value)shadow_softness#@#nSet blur (0–1)
shadow_softness(effect#)shadow_softness@#Get softness
OPACITY
shadow_opacity#(effect#, value)shadow_opacity#@#nSet opacity (0–1)
shadow_opacity(effect#)shadow_opacity@#Get opacity
COLOR
shadow_color#(effect#, color$)shadow_color#@#$Set color
shadow_color(effect#)shadow_color@#Get color
EFFECT CONTROL
shadow_enabled#(effect#, value)shadow_enabled#@#nEnable/disable
shadow_enabled(effect#)shadow_enabled@#Get enabled state
shadow_trigger#(effect#, trigger$)shadow_trigger#@#$Set trigger
shadow_trigger$(effect#)shadow_trigger$@#Get trigger
ERROR HANDLING
shadow_error()shadow_error@Last error code
shadow_errormsg$()shadow_errormsg$@Last error message
shadow_strerror$(code)shadow_strerror$@nCode to text
shadow_clearerror()shadow_clearerror@Clear error state

See Also

LibraryDescription
GlowEffectLibOuter glow effects
InnerGlowEffectLibInner glow effects
BevelEffectLib3D bevel effects
ReflectionEffectLibMirror reflection effects