Jump to content
How to Install Plugins ×

Enormators Effects


Enormator

Recommended Posts

there are two problems with the lense flare thing:

1. I can't draw lines from up to down because... I don't know why I can't! These lines should be only one from the top to the point where they end and at their end they shouldn't begin again with white but stay black!

bug01ebf_thumb.jpg

I have used alpha to grayscale on it to make it better viewable.

2. This is amazingly slow in rendering and I have no idea why.

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);

 // Create a random number to initiate the reseed value
 int reseed = 0;
 Random randinit = new Random();
 if (reseed == 0) reseed = randinit.Next((int)(rect.Bottom * rect.Right + 1));

 // rand = Random number generator
 Random rand = new Random(reseed);
   // Delete any of these lines you don't need
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

   long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left);
   long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top);
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
   ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
   int BrushWidth = (int)EnvironmentParameters.BrushWidth;

   ColorBgra CurrentPixel;
   for(int x = rect.Left; x < rect.Right; x++)
   {
       int lenght = rand.Next(selection.Bottom - selection.Top -1) + 1;
       for (int y = selection.Top; y < selection.Bottom; y++)
       {
           if ((selectionRegion.IsVisible(x, y)) && (y<=lenght))
           {
               if ((y <= lenght) && (y == 0 || (src[x,y - 1].A != 0)))
               {
               CurrentPixel = src[x,y];
               // TODO: Add pixel processing code here
               // Access RGBA values this way, for example:
               CurrentPixel.R = 255;
               CurrentPixel.G = 255;
               CurrentPixel.B = 255;
               CurrentPixel.A = (byte)(255*(lenght-y)/lenght);
               dst[x,y] = CurrentPixel;
               }
           }
       }
   }
}

Any ideas?

Link to comment
Share on other sites

Some answers here...

http://paintdotnet.12.forumer.com/viewtopic.php?t=4996

...the normal way for the renderer is 'for y...for x...'

meaning it works per lines and can't work per columns.

Your code Horizontaly:

void Render(Surface dst, Surface src, Rectangle rect) 
{ 
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); 

 // Create a random number to initiate the reseed value 
 int reseed = 0; 
 Random randinit = new Random(); 
 if (reseed == 0) reseed = randinit.Next((int)(rect.Bottom * rect.Right + 1)); 

 // rand = Random number generator 
 Random rand = new Random(reseed); 

   ColorBgra CurrentPixel; 
   for (int y = rect.Top; y < rect.Bottom; y++) 
   { 
       int lenght = rand.Next(Math.Abs(selection.Left - selection.Right - 1)) + 1; 
       for(int x = rect.Left; x < rect.Right; x++) 
       { 
           if ((selectionRegion.IsVisible(x, y)) && (x<=lenght)) 
           { 
               int xa = x -1;
               if (xa < rect.Left) xa=x;
               if ((x <= lenght) && (x == 0 || (src[x - 1,y].A != 0))) 
               { 
                 CurrentPixel = src[x,y]; 
                 // TODO: Add pixel processing code here 
                 // Access RGBA values this way, for example: 
                 CurrentPixel.R = 255; 
                 CurrentPixel.G = 255; 
                 CurrentPixel.B = 255; 
                 CurrentPixel.A = (byte)(255*(lenght-x)/lenght); 
                 dst[x,y] = CurrentPixel; 
               } 
           } 
       } 
   } 
} 

Link to comment
Share on other sites

Some answers here...

http://paintdotnet.12.forumer.com/viewtopic.php?t=4996

...the normal way for the renderer is 'for y...for x...'

meaning it works per lines and can't work per columns.

Your code Horizontaly:

void Render(Surface dst, Surface src, Rectangle rect) 
{ 
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); 
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); 

 // Create a random number to initiate the reseed value 
 int reseed = 0; 
 Random randinit = new Random(); 
 if (reseed == 0) reseed = randinit.Next((int)(rect.Bottom * rect.Right + 1)); 

 // rand = Random number generator 
 Random rand = new Random(reseed); 

   ColorBgra CurrentPixel; 
   for (int y = rect.Top; y < rect.Bottom; y++) 
   { 
       int lenght = rand.Next(Math.Abs(selection.Left - selection.Right - 1)) + 1; 
       for(int x = rect.Left; x < rect.Right; x++) 
       { 
           if ((selectionRegion.IsVisible(x, y)) && (x<=lenght)) 
           { 
               int xa = x -1;
               if (xa < rect.Left) xa=x;
               if ((x <= lenght) && (x == 0 || (src[x - 1,y].A != 0))) 
               { 
                 CurrentPixel = src[x,y]; 
                 // TODO: Add pixel processing code here 
                 // Access RGBA values this way, for example: 
                 CurrentPixel.R = 255; 
                 CurrentPixel.G = 255; 
                 CurrentPixel.B = 255; 
                 CurrentPixel.A = (byte)(255*(lenght-x)/lenght); 
                 dst[x,y] = CurrentPixel; 
               } 
           } 
       } 
   } 
} 

Link to comment
Share on other sites

(Madjik, yours works, but mine works better! JK, JK, Don't hit me...)

Is this what you're looking for?

untitleddj8.th.png

(Note that I put a BLACK layer under it to properly illustrate...)

//Removed

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

(Madjik, yours works, but mine works better! JK, JK, Don't hit me...)

Is this what you're looking for?

untitleddj8.th.png

(Note that I put a BLACK layer under it to properly illustrate...)

//Removed

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

try this:

//Removed

I noticed that my earlier version didn't "play nice" with layers that already had transparency on them, but now it should work no matter what is already on the layer you run the effect on. I also simplified some of the code.[/code]

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

try this:

//Removed

I noticed that my earlier version didn't "play nice" with layers that already had transparency on them, but now it should work no matter what is already on the layer you run the effect on. I also simplified some of the code.[/code]

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

Well for one thing, like I've said a hundred times before, you don't need the following line of code.

if (selectionRegion.IsVisible(x, y)) 

Remove that will help performance.

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

Well for one thing, like I've said a hundred times before, you don't need the following line of code.

if (selectionRegion.IsVisible(x, y)) 

Remove that will help performance.

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

Well the main problem that was causing the performance to be sooooo slow in Enormator's code was that he was using

for (int y = selection.Top; y 

instead of

[code]for (int y = rect.Top; y

essentially causing each and every call to Render() to process the [i]entire[/i] image instead of just the region that was passed by the rect argument.

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

Well the main problem that was causing the performance to be sooooo slow in Enormator's code was that he was using

for (int y = selection.Top; y 

instead of

[code]for (int y = rect.Top; y

essentially causing each and every call to Render() to process the [i]entire[/i] image instead of just the region that was passed by the rect argument.

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

AWESOME!

ill use the random one all the time

EDIT: bleh, i only thought that from the description. i would use it a lot if you made an option to change the size of the dots or the dots would be as big as your brush size

siggy-1.jpg
Link to comment
Share on other sites

AWESOME!

ill use the random one all the time

EDIT: bleh, i only thought that from the description. i would use it a lot if you made an option to change the size of the dots or the dots would be as big as your brush size

siggy-1.jpg
Link to comment
Share on other sites

bleh, i only thought that from the description. i would use it a lot if you made an option to change the size of the dots or the dots would be as big as your brush size

Is there a way to easiliy draw a rectangle or do I have to use for x... for y...?

(That would be annoying to prog and probably slow in rendering)

Link to comment
Share on other sites

bleh, i only thought that from the description. i would use it a lot if you made an option to change the size of the dots or the dots would be as big as your brush size

Is there a way to easiliy draw a rectangle or do I have to use for x... for y...?

(That would be annoying to prog and probably slow in rendering)

Link to comment
Share on other sites

This will draw a rectangle around the selection using your brushwidth...

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = selectionRegion.GetBoundsInt();
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
   int BrushWidth = (int)EnvironmentParameters.BrushWidth;

   Graphics g = new RenderArgs(dst).Graphics;
   Pen p = new Pen(PrimaryColor.ToColor(),(float)BrushWidth);

   g.DrawRectangle(p, selection);
}

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

This will draw a rectangle around the selection using your brushwidth...

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = selectionRegion.GetBoundsInt();
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
   int BrushWidth = (int)EnvironmentParameters.BrushWidth;

   Graphics g = new RenderArgs(dst).Graphics;
   Pen p = new Pen(PrimaryColor.ToColor(),(float)BrushWidth);

   g.DrawRectangle(p, selection);
}

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

OK, In your earlier post you said that the bars were still repeating even with the version that I posted last, and that was because of a bug that I found and removed. This version is also just a teensy bit faster.

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = selectionRegion.GetBoundsInt();

   Random rand = new Random(0);

   ColorBgra CurrentPixel;
   for(int x = rect.Left; x     {
       int length = rand.Next(selection.Bottom - selection.Top -1) + 1;
       for (int y = rect.Top; y         {
           CurrentPixel = ColorBgra.White;
           CurrentPixel.A = Utility.ClampToByte(255 * (length - y) / length);
           dst[x,y] = CurrentPixel;
       }
   }
}

Gives: untitleddj8.th.png

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

OK, In your earlier post you said that the bars were still repeating even with the version that I posted last, and that was because of a bug that I found and removed. This version is also just a teensy bit faster.

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = selectionRegion.GetBoundsInt();

   Random rand = new Random(0);

   ColorBgra CurrentPixel;
   for(int x = rect.Left; x     {
       int length = rand.Next(selection.Bottom - selection.Top -1) + 1;
       for (int y = rect.Top; y         {
           CurrentPixel = ColorBgra.White;
           CurrentPixel.A = Utility.ClampToByte(255 * (length - y) / length);
           dst[x,y] = CurrentPixel;
       }
   }
}

Gives: untitleddj8.th.png

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

Now that's an awesome effect! I played around a little with CodeLab, and after a bit of figuring, I was able to change it to take a Length parameter from a single slider and use the Primary Color for the cascade effect.

It's probably sloppy, but it works, and it doesn't crash. :D

I am not a mechanism, I am part of the resistance;

I am an organism, an animal, a creature, I am a beast.

~ Becoming the Archetype

Link to comment
Share on other sites

Now that's an awesome effect! I played around a little with CodeLab, and after a bit of figuring, I was able to change it to take a Length parameter from a single slider and use the Primary Color for the cascade effect.

It's probably sloppy, but it works, and it doesn't crash. :D

I am not a mechanism, I am part of the resistance;

I am an organism, an animal, a creature, I am a beast.

~ Becoming the Archetype

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...