GloomEffectLib — Gloom / Darkening Effect

Creates a darkening/gloom effect on visual controls — the opposite of bloom. Reduces brightness and desaturates colours to produce a moody, subdued atmosphere. Wraps FireMonkey’s TGloomEffect. Works with four independent properties controlling gloom intensity/saturation and base intensity/saturation. 18 functions.

CategoryCountDescription
Error Handling4gloom_error, errormsg$, strerror$, clearerror
Creation & Destruction2gloom# (create), gloom_free (destroy)
Gloom Properties4gloomintensity, gloomsaturation (get/set)
Base Properties4baseintensity, basesaturation (get/set)
Effect Control4enabled, trigger (get/set)

Bloom vs Gloom

FeatureBloomGloom
EffectBrightens, adds luminous haloDarkens, reduces brightness
MoodDreamy, ethereal, warmMoody, dark, dramatic
SaturationCan enhance coloursCan desaturate to grayscale
Best forHighlights, heavenly glowDark themes, noir, horror

Properties

PropertyRangeDefaultDescription
GloomIntensity0.0–1.00.5Strength of the darkening effect
BaseIntensity0.0–1.01.0Brightness of the original image
GloomSaturation0.0–1.01.0Colour saturation of the gloom areas
BaseSaturation0.0–1.01.0Colour saturation of the base image (0 = grayscale)

Cross-Platform Support

PlatformStatusNotes
Windows✅ Full SupportGPU-accelerated via Direct2D
Linux✅ Full SupportSoftware rendering fallback
Android✅ Full SupportGPU-accelerated

Error Handling

FunctionSignatureDescription
gloom_error()gloom_error@Returns last error code (0 = no error)
gloom_errormsg$()gloom_errormsg$@Returns last error message
gloom_strerror$(code)gloom_strerror$@nConverts error code to text
gloom_clearerror()gloom_clearerror@Clears the error state

Creation & Destruction

FunctionSignatureDescription
gloom#(parent#)gloom#@#Creates a gloom effect on the given control. Returns the effect pointer.
gloom_free(effect#)gloom_free@#Destroys the effect.

Gloom Properties

FunctionSignatureDescription
gloom_gloomintensity#(effect#, value)gloom_gloomintensity#@#nSets darkening intensity (0.0–1.0)
gloom_gloomintensity(effect#)gloom_gloomintensity@#Gets gloom intensity
gloom_gloomsaturation#(effect#, value)gloom_gloomsaturation#@#nSets gloom area saturation (0.0–1.0)
gloom_gloomsaturation(effect#)gloom_gloomsaturation@#Gets gloom saturation

Base Properties

FunctionSignatureDescription
gloom_baseintensity#(effect#, value)gloom_baseintensity#@#nSets base image brightness (0.0–1.0)
gloom_baseintensity(effect#)gloom_baseintensity@#Gets base intensity
gloom_basesaturation#(effect#, value)gloom_basesaturation#@#nSets base saturation (0 = grayscale)
gloom_basesaturation(effect#)gloom_basesaturation@#Gets base saturation
ⓘ Grayscale shortcut: Setting basesaturation to 0 converts the entire image to grayscale, regardless of other settings.

Effect Control

FunctionSignatureDescription
gloom_enabled#(effect#, value)gloom_enabled#@#nEnables (1) or disables (0)
gloom_enabled(effect#)gloom_enabled@#Gets enabled state
gloom_trigger#(effect#, trigger$)gloom_trigger#@#$Sets trigger string
gloom_trigger$(effect#)gloom_trigger$@#Gets trigger string

Complete Examples

Basic Gloom on Image

╯ gloom-basic.bas
let frm# = Pointer#(0)
let img# = Pointer#(0)
let glm# = Pointer#(0)

frm# = form#("Gloom Demo", 400, 320)

img# = image#(frm#)
image_bounds#(img#, 100, 40, 200, 150)
image_load#(img#, "https://picsum.photos/200/150")

glm# = gloom#(img#)
gloom_gloomintensity#(glm#, 0.5)

form_show(frm#)

Intensity Presets

╯ gloom-presets.bas
let frm# = Pointer#(0)
let img# = Pointer#(0)
let glm# = Pointer#(0)
let lbl# = Pointer#(0)

frm# = form#("Gloom Control", 450, 380)

img# = image#(frm#)
image_bounds#(img#, 125, 30, 200, 150)
image_load#(img#, "https://picsum.photos/200/150")

glm# = gloom#(img#)
gloom_gloomintensity#(glm#, 0)

lbl# = label#(frm#, "Gloom: Off", 175, 200)

let btn1# = button#(frm#, "Off")
button_bounds#(btn1#, 50, 240, 80, 30)
button_onclick#(btn1#, "SetOff")

let btn2# = button#(frm#, "Light")
button_bounds#(btn2#, 140, 240, 80, 30)
button_onclick#(btn2#, "SetLight")

let btn3# = button#(frm#, "Medium")
button_bounds#(btn3#, 230, 240, 80, 30)
button_onclick#(btn3#, "SetMedium")

let btn4# = button#(frm#, "Dark")
button_bounds#(btn4#, 320, 240, 80, 30)
button_onclick#(btn4#, "SetDark")

form_show(frm#)

function SetOff(sender#)
  gloom_gloomintensity#(glm#, 0)
  label_text#(lbl#, "Gloom: Off")
endfunction

function SetLight(sender#)
  gloom_gloomintensity#(glm#, 0.3)
  label_text#(lbl#, "Gloom: 30%")
endfunction

function SetMedium(sender#)
  gloom_gloomintensity#(glm#, 0.5)
  label_text#(lbl#, "Gloom: 50%")
endfunction

function SetDark(sender#)
  gloom_gloomintensity#(glm#, 0.8)
  label_text#(lbl#, "Gloom: 80%")
endfunction

Saturation Control — Colour to Grayscale

╯ gloom-saturation.bas
let frm# = Pointer#(0)
let img# = Pointer#(0)
let glm# = Pointer#(0)
let lbl# = Pointer#(0)

frm# = form#("Saturation Control", 450, 380)

img# = image#(frm#)
image_bounds#(img#, 125, 30, 200, 150)
image_load#(img#, "https://picsum.photos/200/150")

glm# = gloom#(img#)
gloom_gloomintensity#(glm#, 0.4)

lbl# = label#(frm#, "Saturation: 100%", 155, 200)

let btn1# = button#(frm#, "0%")
button_bounds#(btn1#, 80, 240, 80, 30)
button_onclick#(btn1#, "SetSat0")

let btn2# = button#(frm#, "50%")
button_bounds#(btn2#, 180, 240, 80, 30)
button_onclick#(btn2#, "SetSat50")

let btn3# = button#(frm#, "100%")
button_bounds#(btn3#, 280, 240, 80, 30)
button_onclick#(btn3#, "SetSat100")

form_show(frm#)

function SetSat0(sender#)
  gloom_basesaturation#(glm#, 0)
  label_text#(lbl#, "Saturation: 0% (Grayscale)")
endfunction

function SetSat50(sender#)
  gloom_basesaturation#(glm#, 0.5)
  label_text#(lbl#, "Saturation: 50%")
endfunction

function SetSat100(sender#)
  gloom_basesaturation#(glm#, 1.0)
  label_text#(lbl#, "Saturation: 100%")
endfunction

Best Practices

PracticeWhy
Use on images, not solid shapesSolid colours show little visible gloom effect
GloomIntensity 0.3–0.5 for moodSubtle darkening for dark UI themes
BaseSaturation 0 for grayscaleQuick way to desaturate any image
Combine GloomIntensity + BaseSaturation 0Dark desaturated noir look
Opposite of BloomEffectLibUse bloom for highlights, gloom for shadows
Animate with FloatAnimationLibSmoothly transition from bright to dark moods

Quick Reference

FunctionSignatureDescription
ERROR HANDLING
gloom_error()gloom_error@Last error code
gloom_errormsg$()gloom_errormsg$@Last error message
gloom_strerror$(code)gloom_strerror$@nError code to text
gloom_clearerror()gloom_clearerror@Clear error state
CREATION & DESTRUCTION
gloom#(parent#)gloom#@#Create effect on control
gloom_free(effect#)gloom_free@#Destroy effect
GLOOM PROPERTIES
gloom_gloomintensity#(e#, val)gloom_gloomintensity#@#nSet darkening (0–1)
gloom_gloomintensity(e#)gloom_gloomintensity@#Get darkening
gloom_gloomsaturation#(e#, val)gloom_gloomsaturation#@#nSet gloom saturation
gloom_gloomsaturation(e#)gloom_gloomsaturation@#Get gloom saturation
BASE PROPERTIES
gloom_baseintensity#(e#, val)gloom_baseintensity#@#nSet base brightness
gloom_baseintensity(e#)gloom_baseintensity@#Get base brightness
gloom_basesaturation#(e#, val)gloom_basesaturation#@#nSet base saturation
gloom_basesaturation(e#)gloom_basesaturation@#Get base saturation
EFFECT CONTROL
gloom_enabled#(e#, val)gloom_enabled#@#nEnable (1) / disable (0)
gloom_enabled(e#)gloom_enabled@#Get enabled state
gloom_trigger#(e#, str$)gloom_trigger#@#$Set trigger string
gloom_trigger$(e#)gloom_trigger$@#Get trigger string

18 functions. Part of the Plan9Basic visual effects library system.

See Also

  • BloomEffectLib — Opposite effect (brightening/glow)
  • ContrastEffectLib — Contrast adjustment
  • SepiaEffectLib — Sepia tone colouring
  • MonochromeEffectLib — Single colour conversion
  • FloatAnimationLib — Animate gloom properties