Followers 0

# Sine Wave Distort Plugin (ymd:100718)

## 27 posts in this topic

Sine Wave Distort Effect Plugin

What's this?

I think it will solve the problem...

=>

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'...

Plugin SinWaves.dll

Here is the DLL

The source is available with the plugins package!

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

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.

_________________

Some examples:

The model is a centered flag 200x150 with transparent borders and a gradient background.

With default settings: A=5, H=0, V=1

Inverted waves: A=5, H=0, V=-3

Combined effect: A=10,H=3,V=-3

TIP: for flags, it's better to have H and V with opposite sign!

Up to you now to use Gif software to create animated flag...

0

##### Share on other sites

ofcourse now you need to add anti-aliasing

0

##### Share on other sites

I cant use it on my paint.net

0

##### Share on other sites

Rikku, you're gonna get yelled at if you don't resize your avatar. (It should be no bigger than 100x100px I think.)

0

##### 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.

0

##### Share on other sites

Oh Madjik, excellent. I've been hoping for something like this for a long time, and it could actually help me out a lot with a project I'm doing for a friend. Thanks!

0

##### Share on other sites

You completely solved my problem, Madjik! Awesome plugin.

0

##### Share on other sites

Very nice, Thanks again

0

##### Share on other sites

I can really see myself using this a ton from here on out. Really wish it had antialising though, but besides that, its great.

0

##### 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));
}
}
}
}
```

0

##### Share on other sites

Look at the first post of this topic for the lastest version of the Sine Waves plugin.

=>

0

##### Share on other sites

:shock: Hypnotized....

0

##### 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]

0

##### 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

0

##### Share on other sites

Jeez MadJik, you just keep popping out these great plugins don't you? Are you a secret military AI robot?

0

##### 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

0

##### 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

0

##### 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]

Default fixed...TY for reporting!

BTW I found few other plugin in this case, so I made a package you could download at once including SinWave:

Plugin SinWaves.dll

Here is the zip for the pack of DLL

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

0

##### Share on other sites

That is cool

How do you do that?

0

##### 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...

0

##### Share on other sites

Ahhh......Rect2polar...

Thats what I needed to know

Thanks!

0

##### 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.
0

##### Share on other sites

Yes a good package of plugins this will come in handy. Ty Madjik.

0

##### Share on other sites

I've never saw this plugin earlier! Cool.

0

0