Sign in to follow this  
MadJik

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

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

 

 

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

 

Edited by MadJik
refresh UI and rehosted images

Share this post


Link to post
Share on other sites
I cant use it on my paint.net

Works OK for me. Thanks MadJik. Great work.

RikkuBubbles resize your avater. It is to big.

Share this post


Link to post
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));
     }
   } 
 } 
} 

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Even better :)

Thanks!

It's not only good for making flags wave.

It is good for many other things, like Patterns for one.

I'm gonna have a lot of fun playing with this plugin :)

e99067e4.jpg

b7c1a13d.jpg

Share this post


Link to post
Share on other sites

@dawn a few posts back

avatars are supposed to be no more than 100 wide, but i see people with more than that, as long as its not an excessive size difference, im not sure anybody cares

Share this post


Link to post
Share on other sites
Jeez MadJik, you just keep popping out these great plugins don't you? Are you a secret military AI robot?

Yeah, both of you are :)

Share this post


Link to post
Share on other sites
Bob said:
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]

Default fixed...TY for reporting!

 

@Ash: Yes, a lot of possibilities...

test.png

Share this post


Link to post
Share on other sites
That is cool :)

How do you do that?

1.Gradient 30-60° from corner to corner.

2.Sine Waves: Ampl=max, Hor=+/-0.5, Ver=+/-0.5.

3.Duplcate, F4, Blend mode=Negation

4.Flip layer horizontal

5.Merge down (flip vertical for tests)

6.Rect2polar...

Various results...

Share this post


Link to post
Share on other sites
Jeez MadJik, you just keep popping out these great plugins don't you? Are you a secret military AI robot?
Ya madjik u do keep coming out with some gret plugins. Keep up the good work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this