Jump to content
How to Install Plugins ×

Sine Wave Distort Plugin (ymd:100718)


Recommended Posts

Sine Wave Distort Effect Plugin

 

What's this?

I think it will help for this problem...

Sin_Wave00.png  =>   Sin_Wave.gif

 

How does it works?

That uses the function sine to apply a horizontal or vertical shift like a simple or combined wave.

While moving, if the image leaves the area on a side then it reappears on the opposite side.

TIP: Enlarge the canvas with a transparent border to keep the image 'inside'...

 

 

Download the DLL

Plugin SinWaves.dll

ar.pngHere is the DLLal.png

 

The MadJik's All plugins package is available !

http://forums.getpaint.net/index.php?showtopic=7186

 

 

How to install

Close Paint.net

 

Classic version of Paint.net

Unzip and (re)place the DLL in your Effect folder usually: C:/Program Files/Paint.NET/Effects

 

Microsoft Store version of Paint.net

Unzip and (re)place the DLL in your Effect folder usually: /My Documents/paint.net App Files/Effects/

You have to adapt for your language My Documents

 

 

The User interface

This plugin is added to the menu Effects, submenu Distort.

Sin_Waves_UI.png

 

Amplitude (-500,+500, dft 5)

__Sine function gives a result between -1 and 1. You could change this range with the amplitude. The waves could be flat (amount near 0) or high (big amount).

You could use negative values to invert the waves.

Horizontal periods (-500,+500, dft 0)

__A period for the function sine is the full "wave" curve going thru the values : 0,1,0,-1,0. You could choose the number of periods you need...

Vertical periods (-500,+500, dft 1)

__Same for the vertical periods. You could combine Horizontal & Vertical effects...

Angle of start (0,360, dft 0)

__Choosing the angle allows you to start somewhere in the curse of sine...

Anti-alias level (0,10, dft 2)

__It's more a local blur than Anti-aliasing. You choose the level (radius) here.

_________________

Example:

model.jpg

Sin_Waves01.jpg

 

Link to comment
Share on other sites

You could try this code in CodeLab, it's including anti-aliasing (it's some kind of blur in fact)... I need more time to create the DLL with 4 sliders...

int Amount1=500;      //[-9999,9999] Amplitude(/100)
int Amount2=000;      //[-9999,9999] Horizontal periods(/100)
int Amount3=100;      //[-9999,9999] Vertical periods(/100)

void Render(Surface dst, Surface src, Rectangle rect) 
{ 
 PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
 int MaxX = dst.Width;
 int MaxY = dst.Height;
 int MidX = MaxX/2;
 int MidY = MaxY/2;
 double Radius = (double)Amount1 / 100.0; 
 double XCoef  = (double)Amount3 / 100.0;
 double YCoef  = (double)Amount2 / 100.0;

 // Variables for Anti-Aliasing 
 int aaLevel = 2; //Anti-Alias level (no slider!)
 int aaSamples = aaLevel * aaLevel + 1;
 PointF[] aaPoints = new PointF[aaSamples];

 // Init table for AA (don't ask me how it works)  
 for (int s = 0; s < aaSamples; ++s)
 {
   double x = (s * aaLevel) / (double)aaSamples;
   double y = s / (double)aaSamples;
   x -= (int)x;
   // RGSS + rotation to maximize AA quality
   aaPoints[s] = new PointF((float)x, (float)y);
 }

 double xk = 0;
 if ((Radius !=0) && (XCoef !=0)) xk = 2.0 * Math.PI / (MaxX / XCoef);
 double yk = 0;
 if ((Radius !=0) && (YCoef !=0)) yk = 2.0 * Math.PI / (MaxY / YCoef);

 for (int y = rect.Top; y < rect.Bottom; y++) 
 { 
   for (int x = rect.Left; x < rect.Right; x++) 
   { 
     if (aaLevel <=0)
     {
       double yreflect = (double)y;
       if ((Radius !=0) && (XCoef !=0)) yreflect += (double)((Radius * Math.Sin(x * xk)) % MaxY);
       int dy = (int)(0.5 + yreflect);
       if (dy < 0) dy += src.Height; 
       if (dy >= src.Height) dy -= src.Height; 

       double xreflect = (double)x;
       if ((Radius !=0) && (YCoef !=0)) xreflect += (double)((Radius * Math.Sin(y * yk)) % MaxX);
       int dx = (int)(0.5 + xreflect);
       if (dx < 0) dx += src.Width; 
       if (dx >= src.Width) dx -= src.Width; 

       dst[x, y] = src.GetBilinearSample(dx, dy);
     }
     else
     {
       int b = 0, g = 0, r = 0, a = 0;
       foreach (PointF pt in aaPoints)
       {
         double yreflect = (double)(pt.Y + y);
         if ((Radius !=0) && (XCoef !=0)) yreflect += (double)((Radius * Math.Sin(x * xk)) % MaxY);
         int dy = (int)(0.5 + yreflect);
         if (dy < 0) dy += src.Height; 
         if (dy >= src.Height) dy -= src.Height; 

         double xreflect = (double)(pt.X + x);
         if ((Radius !=0) && (YCoef !=0)) xreflect += (double)((Radius * Math.Sin(y * yk)) % MaxX);
         int dx = (int)(0.5 + xreflect);
         if (dx < 0) dx += src.Width; 
         if (dx >= src.Width) dx -= src.Width; 

         ColorBgra sample = src.GetBilinearSampleWrapped(dx, dy);

         b += sample.B;
         g += sample.G;
         r += sample.R;
         a += sample.A;
       }
       dst[x, y] = ColorBgra.FromBgra((byte)(b / aaSamples), (byte)(g / aaSamples), (byte)(r / aaSamples), (byte)(a / aaSamples));
     }
   } 
 } 
} 

Link to comment
Share on other sites

Bug report:

The OK and Cancel button are inverted.

The default PdN dialog layout is :

[OK] [Cancel]

In this Plugin we have:

[Reset All] [Cancel] [OK]

No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio

Link to comment
Share on other sites

  • 3 weeks later...
  • 5 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.

×
×
  • Create New...