Thanks
I appologize for the bugs:
bug or feature: The B&W areas are connected by a 1 meter ramp.
bug: The linewidth are the double of the specified.
serious bug: The algorithm can not be used for small grid sizes
I think I have an solution, I will be back
Ok, I think this version is correct although a bit more complicated: