Jump to content

Flipping selections


Recommended Posts

Hmm... good point, never even thought of that! You can flip selections in v2.5, but it's still a manual process that isn't precise (using the Move Selection tool). I'll file a bug to see about doing this, such as adding a Edit->Flip Selection type of menu item.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

In version 2.5, selections make a lot more sense (we haven't released the source code yet). There's an actual Selection class that is maintained by the DocumentEnvironment.

All you'd have to do to flip the selection horizontally would be the following code:

Workspace.Environment.Selection.PerformChanging();

using (Matrix matrix = new Matrix())
{
   matrix.Reset();
   int width = Workspace.Document.Width;
   matrix.Translate(-((double)width / 2.0), 0, MatrixOrder.Append);
   matrix.Scale(-1.0, 1.0, MatrixOrder.Append);
   matrix.Translate((double)width / 2.0, 0, MatrixOrder.Append);

   Workspace.Environment.Selection.SetInterimTransform(matrix);
   Workspace.Environment.Selection.CommitInterimTransform();
}

Workspace.Environment.Selection.PerformChanged();

Note that this flips it such that the left side of the canvas maps to the right side of the canvas. You could also easily make it so that the left side of the selection is mapped to the right side of the selection. So a selection concentrated at the upper-left of the canvas would stay in the upper-left of the canvas.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...