Jump to content

Recommended Posts

BoltBait's Skew Plugin v1.0

 

Once installed, find Skew Horizontal and Skew Vertical in the Effects > Distort menu:

 

SkewUI.png

Skew Vertical pretty much looks the same.

 

Download:

 

Until I add this to my latest plugin pack, you can download it here...

 

Skew.zip

 

To install this plugin, download skew.zip to your desktop, unzip all files to your desktop, and run the Install_Skew.bat file to install the Skew.dll file to your Paint.NET Effects directory.

 

Source Code:

 

Spoiler


// Name: Skew Horizontal
// Submenu: Distort
// Author: BoltBait
// Title: BoltBait's Skew - Horizontal v1.0
// Version: 1.0
// Desc: Skew selection
// Keywords: skew
// URL: https://BoltBait.com/pdn
// Force Aliased Selection
#region UICode
IntSliderControl Amount1 = 0; // [-50,50] 
CheckboxControl Amount5 = true; // Fine Control
CheckboxControl Amount4 = true; // Clamp to Selection
CheckboxControl Amount2 = false; // Nearest Neighbor
CheckboxControl Amount3 = false; // Wrapped
#endregion

Surface selectionSurface = null;

void PreRender(Surface dst, Surface src)
{
    // Thanks to toe_head2001 for this PreRender code
    // which is useful for clamping to selection
    Rectangle selection = this.EnvironmentParameters.SelectionBounds;
    if (selectionSurface == null || selectionSurface.Size != selection.Size)
    {
        selectionSurface?.Dispose(); selectionSurface = null;
        selectionSurface = new Surface(selection.Size);
    }
    selectionSurface.CopySurface(src, Point.Empty, selection);
}

void Render(Surface dst, Surface src, Rectangle rect)
{
    int Step = Amount1;
    if (!Amount5)
    {
        Step *= 10;
    }
    Rectangle selection = EnvironmentParameters.SelectionBounds;
    float CenterY = ((selection.Bottom - selection.Top) / 2f) + selection.Top;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        float p = (CenterY - y) / (CenterY - selection.Top);
        for (int x = rect.Left; x < rect.Right; x++)
        {
            float XOffset = (-Step) * p;
            if (Amount3)
            {
                if (Amount2)
                {
                    if (Amount4)
                    {
                        dst[x,y] = selectionSurface.GetBilinearSampleWrapped((int)(x+XOffset-selection.Left), y-selection.Top);
                    }
                    else
                    {
                        dst[x,y] = src.GetBilinearSampleWrapped((int)(x+XOffset), y);
                    }
                }
                else
                {
                    if (Amount4)
                    {
                        dst[x,y] = selectionSurface.GetBilinearSampleWrapped(x+XOffset-selection.Left, y-selection.Top);
                    }
                    else
                    {
                        dst[x,y] = src.GetBilinearSampleWrapped(x+XOffset, y);
                    }
                }
            }
            else
            {
                if (Amount2)
                {
                    if (Amount4)
                    {
                        dst[x,y] = selectionSurface.GetBilinearSampleClamped((int)(x+XOffset-selection.Left), y-selection.Top);
                    }
                    else
                    {
                        dst[x,y] = src.GetBilinearSampleClamped((int)(x+XOffset), y);
                    }
                }
                else
                {
                    if (Amount4)
                    {
                        dst[x,y] = selectionSurface.GetBilinearSampleClamped(x+XOffset-selection.Left, y-selection.Top);
                    }
                    else
                    {
                        dst[x,y] = src.GetBilinearSampleClamped(x+XOffset, y);
                    }
                }
            }
        }
    }
}

 

 

Enjoy. 😎 :beer:

  • Like 3
  • Upvote 2

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to post
Share on other sites
  • BoltBait changed the title to Skew v1.0 (with source code)
  • 2 weeks later...

BoltBait  I Really like this.  I don't understand it, but I do like the pretty skews and skew-ers  and all.  I have enclosed a mighty work of artistic doggerel, to show you.

p.s. pay no attention to me, it is a great bit of program writer-ry  an all.

bolt-bait-skew-repair.jpg

  • Like 1

           Scooter

  Age is only  a number --in my case a Really BIG number, but there you have it

When the prefect paint.net image is created, I will still be wondering "How they Do that?"- sigh☺️

       

Link to post
Share on other sites

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.

×
×
  • Create New...