EmbossEffectLib — Emboss Effect

Creates a 3D raised-surface emboss effect on visual controls, simulating a pressed or stamped appearance using highlight and shadow edge detection. Wraps FireMonkey’s TEmbossEffect. Useful for giving flat controls a tactile, physical look — like letters stamped into metal or raised lettering on a coin. 14 functions.

CategoryCountDescription
Error Handling4emboss_error, errormsg$, strerror$, clearerror
Creation & Destruction2emboss# (create), emboss_free (destroy)
Properties4amount, width (get/set)
Effect Control4enabled, trigger (get/set)

How Emboss Works

The emboss effect detects edges in the source image and applies directional lighting simulation: one side of each edge gets a highlight (light), the other gets a shadow (dark). This creates the illusion that the surface is raised or pressed.

╯ emboss-principle
Original:         Embossed:
+----------+      +----------+
| PLAN9    |      | ░PLAN9▓  |   ░ = highlight (light side)
| BASIC    |      | ░BASIC▓  |   ▓ = shadow   (dark side)
+----------+      +----------+
                  Light source: top-left

Two properties control the result:

PropertyRangeDefaultControls
Amount0.0 – 1.00.5How much of the emboss effect blends with the original — intensity/strength
Width0.0 – 10.01.0How wide the highlight/shadow edges are — edge thickness in pixels

Amount Ranges

AmountVisual EffectUse Case
0.0No emboss — original appearanceEffect present but invisible
0.1–0.3Subtle raised surfaceElegant, understated 3D
0.4–0.6Clear emboss with good detailDefault look, balanced
0.7–0.9Strong emboss, dominates appearanceDramatic, artistic
1.0Full emboss — pure edge renderingEdge-map visualization

Width Ranges

WidthVisual EffectUse Case
0.5–1.0Thin, crisp edgesFine detail, text, sharp shapes
1.0–3.0Medium edgesGeneral-purpose emboss
3.0–6.0Wide, soft edgesBold 3D look, large controls
6.0–10.0Very wide, exaggeratedArtistic/stylized effects

Cross-Platform Support

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

Error Handling

FunctionSignatureDescription
emboss_error()emboss_error@Returns last error code (0 = no error)
emboss_errormsg$()emboss_errormsg$@Returns last error message as string
emboss_strerror$(code)emboss_strerror$@nConverts an error code to descriptive text
emboss_clearerror()emboss_clearerror@Clears the error state

Error Codes

CodeConstantMeaning
0ERR_NONENo error
1ERR_NIL_EFFECTEffect pointer is nil
2ERR_INVALID_EFFECTPointer is not a valid TEmbossEffect
3ERR_INVALID_VALUEProperty value out of range
4ERR_NIL_PARENTParent control pointer is nil
5ERR_INVALID_PARENTPointer is not a valid TFmxObject

Creation & Destruction

FunctionSignatureDescription
emboss#(parent#)emboss#@#Creates an emboss effect on the given control. Returns the effect pointer.
emboss_free(effect#)emboss_free@#Destroys the effect and removes it from the parent.

Amount

Controls the intensity of the emboss effect — how much the 3D raised appearance blends with the original image. Range 0.0–1.0, default 0.5.

FunctionSignatureDescription
emboss_amount#(effect#, value)emboss_amount#@#nSets amount (0.0–1.0)
emboss_amount(effect#)emboss_amount@#Gets current amount
╯ amount-presets.bas
' Subtle 3D hint
emboss_amount#(emb#, 0.2)

' Balanced default
emboss_amount#(emb#, 0.5)

' Bold dramatic emboss
emboss_amount#(emb#, 0.9)

Width

Controls the edge thickness of the highlight and shadow bands. Range 0.0–10.0, default 1.0. Wider edges create a bolder, more dramatic 3D look.

FunctionSignatureDescription
emboss_width#(effect#, value)emboss_width#@#nSets width (0.0–10.0)
emboss_width(effect#)emboss_width@#Gets current width

Effect Control

Enabled

FunctionSignatureDescription
emboss_enabled#(effect#, value)emboss_enabled#@#nEnables (1) or disables (0)
emboss_enabled(effect#)emboss_enabled@#Gets enabled state

Trigger

FunctionSignatureDescription
emboss_trigger#(effect#, trigger$)emboss_trigger#@#$Sets trigger string
emboss_trigger$(effect#)emboss_trigger$@#Gets current trigger string

Complete Examples

Basic Emboss on Rectangle

╯ emboss-basic.bas
let frm# = Pointer#(0)
let rect# = Pointer#(0)
let emb# = Pointer#(0)

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

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

emb# = emboss#(rect#)
emboss_amount#(emb#, 0.5)
emboss_width#(emb#, 2)

form_show(frm#)

Intensity Presets with Buttons

╯ emboss-presets.bas
let frm# = Pointer#(0)
let rect# = Pointer#(0)
let emb# = Pointer#(0)
let lbl# = Pointer#(0)

frm# = form#("Emboss Control", 450, 320)

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

emb# = emboss#(rect#)
emboss_amount#(emb#, 0.5)
emboss_width#(emb#, 2)

lbl# = label#(frm#, "Amount: 0.5", 170, 160)

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

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

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

form_show(frm#)

function SetLight(sender#)
  emboss_amount#(emb#, 0.2)
  label_text#(lbl#, "Amount: 0.2")
endfunction

function SetMedium(sender#)
  emboss_amount#(emb#, 0.5)
  label_text#(lbl#, "Amount: 0.5")
endfunction

function SetStrong(sender#)
  emboss_amount#(emb#, 0.9)
  label_text#(lbl#, "Amount: 0.9")
endfunction

Width Comparison — Side by Side

╯ emboss-widths.bas
let frm# = Pointer#(0)
let rect1# = Pointer#(0)
let rect2# = Pointer#(0)
let rect3# = Pointer#(0)
let emb1# = Pointer#(0)
let emb2# = Pointer#(0)
let emb3# = Pointer#(0)

frm# = form#("Emboss Width", 500, 280)

' Thin width
rect1# = rectangle#(frm#)
rectangle_bounds#(rect1#, 40, 60, 120, 100)
rectangle_fill#(rect1#, "Silver")
emb1# = emboss#(rect1#)
emboss_amount#(emb1#, 0.5)
emboss_width#(emb1#, 1)
let lbl1# = label#(frm#, "Width: 1", 70, 170)

' Medium width
rect2# = rectangle#(frm#)
rectangle_bounds#(rect2#, 190, 60, 120, 100)
rectangle_fill#(rect2#, "Silver")
emb2# = emboss#(rect2#)
emboss_amount#(emb2#, 0.5)
emboss_width#(emb2#, 3)
let lbl2# = label#(frm#, "Width: 3", 220, 170)

' Wide width
rect3# = rectangle#(frm#)
rectangle_bounds#(rect3#, 340, 60, 120, 100)
rectangle_fill#(rect3#, "Silver")
emb3# = emboss#(rect3#)
emboss_amount#(emb3#, 0.5)
emboss_width#(emb3#, 6)
let lbl3# = label#(frm#, "Width: 6", 370, 170)

form_show(frm#)

Best Practices

PracticeWhy
Use gray or neutral-colored controlsEmboss relies on highlight/shadow contrast — works best on mid-tone surfaces
Start with amount 0.5, width 2Good default that shows the 3D effect clearly without overloading
Lower amount (0.2–0.3) for subtle eleganceProfessional UI look with a hint of depth
Combine with BevelEffectLibBoth create 3D looks but with different edge styles
Use on images for rich texturePhotos show emboss well due to natural edge detail
Match width to control sizeSmall controls need thin width (1–2); large controls can handle 3–6
Use trigger IsMouseOver=trueEmboss on hover gives buttons a “pressed” feeling
Animate amount with FloatAnimationLibSmoothly transition between flat and embossed states

Quick Reference

FunctionSignatureDescription
ERROR HANDLING
emboss_error()emboss_error@Last error code
emboss_errormsg$()emboss_errormsg$@Last error message
emboss_strerror$(code)emboss_strerror$@nError code to text
emboss_clearerror()emboss_clearerror@Clear error state
CREATION & DESTRUCTION
emboss#(parent#)emboss#@#Create effect on control
emboss_free(effect#)emboss_free@#Destroy effect
PROPERTIES
emboss_amount#(effect#, val)emboss_amount#@#nSet amount (0.0–1.0)
emboss_amount(effect#)emboss_amount@#Get amount
emboss_width#(effect#, val)emboss_width#@#nSet width (0.0–10.0)
emboss_width(effect#)emboss_width@#Get width
EFFECT CONTROL
emboss_enabled#(effect#, val)emboss_enabled#@#nEnable (1) / disable (0)
emboss_enabled(effect#)emboss_enabled@#Get enabled state
emboss_trigger#(effect#, str$)emboss_trigger#@#$Set trigger string
emboss_trigger$(effect#)emboss_trigger$@#Get trigger string

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

See Also

  • BevelEffectLib — 3D bevel edge effects
  • SharpenEffectLib — Edge sharpening
  • PaperSketchEffectLib — Sketch/pencil rendering
  • PencilStrokeEffectLib — Pencil stroke artistic effect
  • FloatAnimationLib — Animate amount for interactive emboss