Hi,
I tested your code and it writes me: Warning: Symbol "Scanline" is not portable
So I jumped to source (Graphics.pp) via Alt+ArrowUp and there is a comment by the Scanline property: // Use only when wrpped by a begin/endupdate
So I added it to your code:
src.BeginUpdate(False);
//all the code of the Darkness
src.EndUpdate(True);
and it works.
When it comes to speed, this kind of graphics will always be rather slow.
Anyway
div is a slow operation, you can try bitshift instead (but you will have not fine control).
You can also ommit conversion IntToByte, because it will never go over 255 and beyond 0.
p0[x * 3] := (r - (r shr 3));