We can include this in lazpaint?
Sure but I would encourage to refactor and use a bgrabitmap in that case (that is what lazpain uses, not ?). As for the rest, if the license of the original code allows you to to do so (I was unable to find a license) then feel free and go ahead and copy-paste to your heart's desire. That is exactly what paying forward means: re-use and show off in your project and in case possible improve things.
Thankyou!
You're more than welcome. Thank you for considering to ask and for your contributions.
Attached is a class helper for TFPCustomCanvas. I've rewrote everything using normal procedures and encapsulated that into a helper. Should be easier to make (practical) use of it now and perhaps more adaptable for your use case.
For someone with more knowledge on the Sutcliffe algorithm I want to ask if it is necessary to (explicitly) draw the root branch. The original (js) code does it but I failed to see the difference (but might be because I did not run into a particular case that does require for the root branch to be (explicitly) drawn).
Have Fun !
edit 2023.09.26: Updated the attachment with a fixed version of the helper as the previous version was drawing branches using the wrong points resulting in graphics that can be perceived as missing a nesting iteration.