Jump to content
How to Install Plugins ×

Diagonal Lines Plugin [v2.5, September 13th, 2009]


jsonchiu

Recommended Posts

Very, very useful plugin! Thanks a lot!! :D

Just two suggestions tho:

1. you should remove "if (selectionRegion.IsVisible(x, y))" from your code, as it's not needed and slows the execution of the plugin.

2. you should remove version info from the name of the dll, so that a simple overwriting would update it for the user.

"Be who you are and say what you feel because those who mind don't matter and those who matter don't mind."

~Dr. Seuss

Link to comment
Share on other sites

Btw, is there any way to change the angle of the diagonal lines?

This is what I cooked up with GDI+. Lines with a width greater than 1 don't work nicely currently. This is not a codelab script and requires version 3.20. It currently has a few bugs, probably from mathematical inaccuracies.

DiagonalLines.zip

Link to comment
Share on other sites

I just did some modification (after reviewing trig stuff).

Can anybody just do some interface work for me? Codelab doesn't allow 4 sliders... (duh)

int Amount1=40;	//[3,200] Scanline Interval
int Amount2=1;	//[1,200] Brush Width
int Amount3=5;	//[0,9] Antialias Level
int Amount4=45; //[0,179] Angle

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

   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;

   ColorBgra CurrentPixel;

   //modifying my (x + y) % Amount1 Algorithm, we multiply the x and y by certain value
   double xfactor = 1;
   double yfactor = 1;

   //if y is longer than x, we modify y factor, and vice versa
   if (Amount4 <= 45 || (Amount4 > 135 && Amount4 < 225) || Amount4 > 315)
   {
   	yfactor = Math.Tan(Amount4 * (3.14159/180));
   }
   else
   {
       xfactor = 1 / Math.Tan(Amount4 * (3.14159/180));
   }

   for(int y = rect.Top; y < rect.Bottom; y++)
   {
       for (int x = rect.Left; x < rect.Right; x++)
       {
           if (selectionRegion.IsVisible(x, y))
           {
               CurrentPixel = src[x,y];
               double testnum = (x*xfactor + y*yfactor);
               if (testnum < 0)
               {
                   //make the number a positive before doing the modular (%) operation
                   testnum = testnum + Amount1 * 1000000;
               }
               double modular = testnum % Amount1;

               //if modular < thickness
               if (modular < Amount2)
               {
                   if ((int)(PrimaryColor.A) == 255)
                   {
                       CurrentPixel.R = (byte)PrimaryColor.R;
                       CurrentPixel.G = (byte)PrimaryColor.G;
                       CurrentPixel.B = (byte)PrimaryColor.B;
                       CurrentPixel.A = (byte)PrimaryColor.A;
                   }
                   else
                   {
                       //some code to multiply color to alpha

                       int alpha = (int)(PrimaryColor.A);
                       int inv_alpha = 255 - alpha;
                       CurrentPixel.R = (byte)(((int)(PrimaryColor.R) * alpha + (int)(CurrentPixel.R) * inv_alpha) / 255);
                       CurrentPixel.G = (byte)(((int)(PrimaryColor.G) * alpha + (int)(CurrentPixel.G) * inv_alpha) / 255);
                       CurrentPixel.B = (byte)(((int)(PrimaryColor. * alpha + (int)(CurrentPixel. * inv_alpha) / 255);
                       if ((int)(CurrentPixel.A) < (int)255)
                       {
                           int temp;
                           if ((int)(PrimaryColor.A) + (int)(CurrentPixel.A) >= 255)
                           {
                               temp = 255;
                           }
                           else
                           {
                               temp = (int)(PrimaryColor.A) + (int)(CurrentPixel.A);
                           }
                           CurrentPixel.A = (byte)(((int)(CurrentPixel.A) + temp) / 2);
                       }
                       else
                       {
                           CurrentPixel.A = (byte)255;
                       }
                   }
               }
               else if (Amount3 > 0)
               {
                   //if pixel is beside the line, we do our antialias operation
                   if (modular <= Amount2 + 1 ||
                       modular >= Amount1 - 1)
                   {
                       double factor = 0;
                       if (modular >= Amount1 - 1)
                       {
                           factor = 1 - (modular - Amount1 + 1);
                       }
                       else
                       {
                           factor = 1 - (Amount2 - modular + 1);
                       }

                       //hacks to get around special angles
                       if (Amount4 == 45)
                       {
                           factor += 0.8;
                       }
                       else if (Amount4 == 90)
                       {
                           factor = 0;
                       }
                       else if (Amount4 == 135)
                       {
                           factor -= 0.7;
                       }

                       //our antialias routine
                       int mul = (int)((10 - Amount3) * factor);
                       int div = mul + 1;
                       CurrentPixel.R = (byte)(((int)(PrimaryColor.R) + mul * (int)(CurrentPixel.R)) / div);
                       CurrentPixel.G = (byte)(((int)(PrimaryColor.G) + mul * (int)(CurrentPixel.G)) / div);
                       CurrentPixel.B = (byte)(((int)(PrimaryColor. + mul * (int)(CurrentPixel.) / div);

                       //alpha multiplication
                       if ((int)(CurrentPixel.A) < (int)255)
                       {
                           int temp;
                           if ((int)(PrimaryColor.A) + (int)(CurrentPixel.A) >= (int)255)
                           {
                               temp = 255;
                           }
                           else
                           {
                               temp = (int)(PrimaryColor.A) + (int)(CurrentPixel.A);
                           }
                           CurrentPixel.A = (byte)((temp + mul * (int)(CurrentPixel.A)) / div);
                       }
                       else
                       {
                           CurrentPixel.A = (byte)255;
                       }
                   }
               }

               //and we are done
               dst[x,y] = CurrentPixel;
           }
       }
   }
}

siggiecj5.png

Some links: | Personal Website | Alien Attack |

Try out my plugins: | Antialias | Diagonal Lines |

Link to comment
Share on other sites

I just did some modification (after reviewing trig stuff).

Can anybody just do some interface work for me? Codelab doesn't allow 4 sliders... (duh)

[blah]

I'd do it, but Rick still has breaking changes planned for the 3.20's plugin system. It seems silly to me to write code that you know is going to stop working in a week or two... Once 3.20 goes GM, though, I'd be happy to do it.

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

  • 1 month later...
  • 2 weeks later...

Plugin Crash report:

Settings:

Scanline: 4

Brush: 2

AA: 8

Angle: Crushed while swichtching from 135 to 134

hers the Technical report:

Datei: P:\Grafik\Paint.NET\Effects\Diagonal Lines.dll

Effektname: DiagonalLines.EffectPlugin

Vollständige Fehlermeldung: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.DivideByZeroException: Attempted to divide by zero.

at DiagonalLines.EffectPlugin.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length)

at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderImpl()

--- End of inner exception stack trace ---

at PaintDotNet.Effects.BackgroundEffectRenderer.Join()

at PaintDotNet.Effects.BackgroundEffectRenderer.Start()

at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClassa.b__8(Object sender, EventArgs e)

[E] Tryed that a second one, it crashed again! [/E]

rhfjdjejdca.png
Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...

loks really cool but im having trouble downloading this i have it downloaded to my effects folder and restarted paint.net but it wont work help! :shock:

armysig.png

signature by:me

Link to comment
Share on other sites

  • 3 weeks later...

i really need this plug in but i can't get this to work :oops:

the download doesnt work i get this error but i rite clicked & downloaded it

& then i put in the effects folder but it does not show up so can some one please help :D

Link to comment
Share on other sites

I am having the same problem, I try right clicking then saving, but yet it won't show up anywhere in the effects. I also tried going to the site by typing the url in the search bar and it says that the server is forbidden. Could you try and save the file on a different file sharing site like mediafire or something. Cause this effect sounds very useful to me and I would like to have it badly.

deviantART | Paint.NET Gallery | bennettfrazier.com <-- (My new Website!)

 

Link to comment
Share on other sites

Hey guys I'll mirror the download for you, until he fixes it

jsonchiu's Diagonal lines v2.0 (zip)

http://dl.getdropbox.com/u/40180/Diagonal%20Lines.zip

Really is a great plugin :)

Great, thank you so much! I will really enjoy this plugin :D

Hopefully the author does this too so he can get more downloads on his awesome plugin, lol

deviantART | Paint.NET Gallery | bennettfrazier.com <-- (My new Website!)

 

Link to comment
Share on other sites

  • 8 months later...
you could just use the fill patterns to make diagonal lines

But this plugin allows a wider variety of options, such as spacing between the lines, the size of the lines, etc. so I am not sure the pattern tool is the best option. ;)

deviantART | Paint.NET Gallery | bennettfrazier.com <-- (My new Website!)

 

Link to comment
Share on other sites

  • 2 months later...
Link to comment
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...