FillRGBEffectLib — Solid Color Fill (RGB)

Fills a visual control with a solid colour overlay using a numeric ARGB value. Wraps FireMonkey’s TFillRGBEffect. Functionally very similar to FillEffectLib — both accept ARGB numeric colours and both replace all pixels. 12 functions.

CategoryCountDescription
Error Handling4fillrgb_error, errormsg$, strerror$, clearerror
Creation & Destruction2fillrgb# (create), fillrgb_free (destroy)
Properties2color (get/set)
Effect Control4enabled, trigger (get/set)

Fill vs FillRGB

Both libraries accept numeric ARGB colour values and produce the same visual result. The underlying FireMonkey classes (TFillEffect vs TFillRGBEffect) differ in their internal shader implementation, but from the Plan9Basic programmer’s perspective they are interchangeable.

FeatureFillEffectLibFillRGBEffectLib
Colour inputNumeric ARGBNumeric ARGB
Function count1212
Prefixfill_fillrgb_
WrapsTFillEffectTFillRGBEffect
ⓘ Which to use? Either works. Pick whichever prefix you prefer. Both accept the same ARGB decimal/hex values.

Cross-Platform Support

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

Error Handling

FunctionSignatureDescription
fillrgb_error()fillrgb_error@Returns last error code (0 = no error)
fillrgb_errormsg$()fillrgb_errormsg$@Returns last error message as string
fillrgb_strerror$(code)fillrgb_strerror$@nConverts an error code to descriptive text
fillrgb_clearerror()fillrgb_clearerror@Clears the error state

Error Codes

CodeConstantMeaning
0ERR_NONENo error
1ERR_NIL_EFFECTEffect pointer is nil
2ERR_INVALID_EFFECTPointer is not a valid TFillRGBEffect
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
fillrgb#(parent#)fillrgb#@#Creates a fill RGB effect on the given control. Returns the effect pointer.
fillrgb_free(effect#)fillrgb_free@#Destroys the effect and removes it from the parent.

Color

FunctionSignatureDescription
fillrgb_color#(effect#, color)fillrgb_color#@#nSets fill colour (ARGB number)
fillrgb_color(effect#)fillrgb_color@#Gets current fill colour

Effect Control

Enabled

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

Trigger

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

Complete Examples

Basic Fill on Image

╯ fillrgb-basic.bas
let frm# = Pointer#(0)
let img# = Pointer#(0)
let fl# = Pointer#(0)

frm# = form#("Fill RGB Demo", 400, 320)

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

fl# = fillrgb#(img#)
fillrgb_color#(fl#, 4294901760)  ' Red ($FFFF0000)

form_show(frm#)

Colour Switcher

╯ fillrgb-switch.bas
let frm# = Pointer#(0)
let img# = Pointer#(0)
let fl# = Pointer#(0)
let lbl# = Pointer#(0)

frm# = form#("Fill RGB Colors", 450, 380)

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

fl# = fillrgb#(img#)
fillrgb_enabled#(fl#, 0)

lbl# = label#(frm#, "Fill: Off", 180, 200)

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

let btn2# = button#(frm#, "Red")
button_bounds#(btn2#, 130, 240, 80, 30)
button_onclick#(btn2#, "SetRed")

let btn3# = button#(frm#, "Green")
button_bounds#(btn3#, 220, 240, 80, 30)
button_onclick#(btn3#, "SetGreen")

let btn4# = button#(frm#, "Blue")
button_bounds#(btn4#, 310, 240, 80, 30)
button_onclick#(btn4#, "SetBlue")

form_show(frm#)

function SetOff(sender#)
  fillrgb_enabled#(fl#, 0)
  label_text#(lbl#, "Fill: Off")
endfunction

function SetRed(sender#)
  fillrgb_color#(fl#, 4294901760)
  fillrgb_enabled#(fl#, 1)
  label_text#(lbl#, "Fill: Red")
endfunction

function SetGreen(sender#)
  fillrgb_color#(fl#, 4278255360)
  fillrgb_enabled#(fl#, 1)
  label_text#(lbl#, "Fill: Green")
endfunction

function SetBlue(sender#)
  fillrgb_color#(fl#, 4278190335)
  fillrgb_enabled#(fl#, 1)
  label_text#(lbl#, "Fill: Blue")
endfunction

Toggle Fill On/Off

╯ fillrgb-toggle.bas
let frm# = Pointer#(0)
let img# = Pointer#(0)
let fl# = Pointer#(0)

frm# = form#("Toggle Fill", 400, 320)

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

fl# = fillrgb#(img#)
fillrgb_color#(fl#, 4294967040)  ' Yellow ($FFFFFF00)
fillrgb_enabled#(fl#, 0)

let btn# = button#(frm#, "Toggle Fill")
button_bounds#(btn#, 130, 220, 120, 35)
button_onclick#(btn#, "OnToggle")

form_show(frm#)

function OnToggle(sender#)
  if fillrgb_enabled(fl#) = 1 then
    fillrgb_enabled#(fl#, 0)
  else
    fillrgb_enabled#(fl#, 1)
  endif
endfunction

Quick Reference

FunctionSignatureDescription
ERROR HANDLING
fillrgb_error()fillrgb_error@Last error code
fillrgb_errormsg$()fillrgb_errormsg$@Last error message
fillrgb_strerror$(code)fillrgb_strerror$@nError code to text
fillrgb_clearerror()fillrgb_clearerror@Clear error state
CREATION & DESTRUCTION
fillrgb#(parent#)fillrgb#@#Create effect on control
fillrgb_free(effect#)fillrgb_free@#Destroy effect
PROPERTIES
fillrgb_color#(effect#, color)fillrgb_color#@#nSet colour (ARGB number)
fillrgb_color(effect#)fillrgb_color@#Get colour
EFFECT CONTROL
fillrgb_enabled#(effect#, val)fillrgb_enabled#@#nEnable (1) / disable (0)
fillrgb_enabled(effect#)fillrgb_enabled@#Get enabled state
fillrgb_trigger#(effect#, str$)fillrgb_trigger#@#$Set trigger string
fillrgb_trigger$(effect#)fillrgb_trigger$@#Get trigger string

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

See Also

  • FillEffectLib — Same fill effect, same ARGB API
  • MonochromeEffectLib — Convert to a single colour tone
  • ColorKeyAlphaEffectLib — Make a specific colour transparent