ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Extended layer cloning
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

934 Posts

Posted - May 24 2023 :  10:10:12  Show Profile  Reply
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?

xequte

38683 Posts

Posted - May 24 2023 :  23:14:04  Show Profile  Reply
Hi Peter

That code looks correct.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: