spongey437 Posted September 12, 2007 Share Posted September 12, 2007 (edited) I was looking for a way to make vertical or horizontal lines across a whole image (or a selected region) and who knows, maybe this is already out there somewhere but I also wanted to play around with the CodeLab so i thought I would write it up myself. So here is what it will create - Pretty simple, and even with my limited knowledge of programming I was able to use CodeLab to come up with it. The effect has two slider bars. The first sets the width between the lines (defaults to 10, and I maxed it out at 100, minimum is one but that actually just paints the whole page one color). It uses whatever your primary color selected is as the color of the lines. The second slider is just to determine whether you want Vertical or Horizontal lines (1 for vertical, 2 for horizontal). Here is the source code in case anyone was interested - like I said it is a pretty simple code but it might help some new people see how CodeLab works. Thanks to BoltBait for his tutorials on writing CodeLab plugins as well, they were very helpful. Looking at the code below, all it does is check to see if you want it horizontal or vertical. Then it goes through every pixel and calculates whether that pixel is a factor of the width that you have set. If it is, it writes to that pixel, if not it does nothing. int Amount1=10; //[1,100]Width int Amount2=2; //[1,2]X - Y void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); // 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 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]; // TODO: Add pixel processing code here if(Amount2 == 1) { if (x % Amount1 == 0) { // Access RGBA values this way, for example: CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } } if(Amount2 == 2) { if (y % Amount1 == 0) { // Access RGBA values this way, for example: CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } } dst[x,y] = CurrentPixel; } } } } Well, that's it - my first plugin. Here is the link to the dll - http://Spongey437.googlepages.com/lines.dll Also, this effect will appear in the Render submenu in PdN. I don't know about you guys but I wish all the effects were subgrouped in some way as there are a ton of them now and they go off the page. Lines.zip Edited July 26, 2018 by toe_head2001 Formatting Quote Link to comment Share on other sites More sharing options...
Leif Posted September 12, 2007 Share Posted September 12, 2007 I just tried it. Looks like it could bee useful if you want to make something look like scan lines from a TV. Nice work. Quote My DA: http://leif-j.deviantart.com/ -------------- Some people seek justice so persistent, that they will do great injustice themselves. Link to comment Share on other sites More sharing options...
MiguelPereira Posted September 12, 2007 Share Posted September 12, 2007 this can come in handy Just one thing I think that even if it's a quick rendering plugin It should use the Switch function like this switch(Amount3) { case 1: if (x % Amount2 == 0) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } break; case 2: if (y % Amount2 == 0) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } break; } It might be better for high-res images (really high-res) anyway i was trying to put a line width function. nice work Lines.zip Quote [The stock on my sig is a photo I took not a render from Splatter] [My deviantART][My Gallery][My Space] Link to comment Share on other sites More sharing options...
moc426 Posted September 12, 2007 Share Posted September 12, 2007 There is an interlace plugin, I think it does the same as this. viewtopic.php?f=16&t=4195 Quote Link to comment Share on other sites More sharing options...
MiguelPereira Posted September 12, 2007 Share Posted September 12, 2007 There is an interlace plugin, I think it does the same as this. It doesn't let the space between to be chosen, this one does. This one doesn't have the line width option. Quote [The stock on my sig is a photo I took not a render from Splatter] [My deviantART][My Gallery][My Space] Link to comment Share on other sites More sharing options...
moc426 Posted September 12, 2007 Share Posted September 12, 2007 Ok I see, thats cool, it can be handy. There is an interlace plugin, I think it does the same as this. It doesn't let the space between to be chosen, this one does. This one doesn't have the line width option. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted September 12, 2007 Share Posted September 12, 2007 This function can already be done with this plugin: http://boltbait.googlepages.com/scanlines Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
Jezulkim Posted September 12, 2007 Share Posted September 12, 2007 Well, there's one thing better on this one. It respects your brush colour. The lines are always black with your plugin. EDIT: ... Quote Internet Explorer 7 Link to comment Share on other sites More sharing options...
barkbark00 Posted September 12, 2007 Share Posted September 12, 2007 Well, there's one thing better on this one. It respects your brush colour. The lines are always black with your plugin.EDIT: ... And the line spacing goes up to 100... Quote Take responsibility for your own intelligence. -Rick Brewster Link to comment Share on other sites More sharing options...
usedHONDA Posted September 12, 2007 Share Posted September 12, 2007 Nice, simple plugin, but can't this be achieved with Paint.NET's fill modes? Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb Link to comment Share on other sites More sharing options...
Andrew D Posted September 12, 2007 Share Posted September 12, 2007 this can come in handyJust one thing I think that even if it's a quick rendering plugin It should use the Switch function like this switch(Amount3) { case 1: if (x % Amount2 == 0) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } break; case 2: if (y % Amount2 == 0) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } break; } It might be better for high-res images (really high-res) anyway i was trying to put a line width function. nice work You can get some interesting results with this is if you combine the two scripts together.... int Amount1=10; //[1,100]Width int Amount2=2; //[1,2]X - Y int Amount3=2; //[1,2]Switch void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); // 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 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]; // TODO: Add pixel processing code here if(Amount2 == 1) { if (x % Amount1 == 0) { // Access RGBA values this way, for example: CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } } if(Amount2 == 2) { if (y % Amount1 == 0) { // Access RGBA values this way, for example: CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } } switch(Amount3) { case 1: if (x % Amount2 == 0) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } break; case 2: if (y % Amount2 == 0) { CurrentPixel.R = (byte)PrimaryColor.R; CurrentPixel.G = (byte)PrimaryColor.G; CurrentPixel.B = (byte)PrimaryColor.B; CurrentPixel.A = (byte)PrimaryColor.A; } break; } dst[x,y] = CurrentPixel; } } } } Have a little look for yourself.... although you might have to compile it first. Quote Link to comment Share on other sites More sharing options...
Pantaleao Posted November 25, 2007 Share Posted November 25, 2007 Thanks!! Nice first try at CodeLab! Just a cleanup and a small enhancement to your code, as it seemed to me (from your code) that you were trying to use BrushWidth: int Amount1=10; //[2,100]Line Spacing int Amount2=1; //[1,2]Vertical <-> Horizontal void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { ColorBgra CurrentPixel = src[x,y]; if(Amount2 == 1) { if ((x % Amount1) < BrushWidth) CurrentPixel = PrimaryColor; } else { if ((y % Amount1) < BrushWidth) CurrentPixel = PrimaryColor; } dst[x,y] = CurrentPixel; } } } Quote "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 More sharing options...
jsonchiu Posted November 25, 2007 Share Posted November 25, 2007 If anybody is interested, go to my Diagonal Lines Plugin thread page 2. I've got the script that allows different angles for the lines. The problem is that I cannot compile a 4-slider plugin with Codelab. It would be very helpful if anybody can help me create the interface. (Then, instead of having 1000 plugins about lines, you only need 1) Quote Some links: | Personal Website | Alien Attack | Try out my plugins: | Antialias | Diagonal Lines | Link to comment Share on other sites More sharing options...
MattBlackLamb Posted November 25, 2007 Share Posted November 25, 2007 The new Paint.NET plugin interface has an angle chooser in it, there should be a way to use that instead of a slider, but don't ask me how coz I really don't know. Quote dA Son, someday you will make a girl happy for a short period of time. Then she'll leave you & be with men that are ten times better than you can imagine. These men are called musicians. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.