When cloning a Layer: To avoid the cloned Layer becoming hidden behind the current Layer, I wrote this extended Layer cloning procedure:
with ImageEnView1 do
begin
var X := CurrentLayer.PosX + (Currentlayer.Width div 2); // x-position-center of the current Layer
// x-position of the cloned Layer depending on the horizontal x-position-center of the current Layer:
var _X: Integer;
if X <= (IEBitmap.Width div 2) then
_X := CurrentLayer.PosX + CurrentLayer.Width
else
_X := CurrentLayer.PosX - CurrentLayer.Width;
var OriginalName := CurrentLayer.Name;
LayersInsert(
CurrentLayer.LayerIndex, // Insert position
CurrentLayer, // Layer to clone
_X, // X-Position of the cloned Layer
CurrentLayer.PosY // Y-Position of the cloned Layer
);
CurrentLayer.Name := OriginalName + '_Cloned';
end;
Here is the result:
Can this be simplified in any way?