jsonchiu Posted August 20, 2007 Share Posted August 20, 2007 (edited) I've been searching for a plugin that makes diagonal lines for a long time... Since I couldn't, I decided that maybe I should make one myself! It turned out to be a lot easier than I thought, and here it is! The plugin will be placed under Effects -> Render Download Source: Spoiler #region UICode int Amount1 = 60; // [0,500] Interval int Amount2 = 1; // [0,500] Brush Width int Amount3 = 6; // [0,10] Anti-alias Level int Amount4 = 45; // [0,360] Angle bool Amount5 = true; // [0,1] Use Primary Color ColorBgra Amount6 = ColorBgra.FromBgr(0,0,0); // Color int Amount7 = 255; // [0,255] Alpha #endregion ColorBgra multiplyRGB(ColorBgra CurrentPixel, ColorBgra PrimaryColor, double mul, double div) { double inv_mul = div - mul; if (CurrentPixel.A == 0 || Math.Round(255 * mul/div) == 255) { CurrentPixel.R = PrimaryColor.R; CurrentPixel.G = PrimaryColor.G; CurrentPixel.B = PrimaryColor.B; } else { CurrentPixel.R = (byte)(((int)(PrimaryColor.R) * mul + (int)(CurrentPixel.R) * inv_mul) / div); CurrentPixel.G = (byte)(((int)(PrimaryColor.G) * mul + (int)(CurrentPixel.G) * inv_mul) / div); CurrentPixel.B = (byte)(((int)(PrimaryColor.B) * mul + (int)(CurrentPixel.B) * inv_mul) / div); } return CurrentPixel; } int multiplyAlpha(int currentA, int newA) { //if no alpha needed to add or if totally opaque if (newA == 0 || currentA == 255) { return currentA; } //if current alpha is zero, new alpha would not need adjustment else if (currentA == 0 || newA == 255) { return newA; } else if (currentA < 255) { currentA += newA * (255 - currentA) / 255; return currentA; } return 0; } void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra CurrentPixel; int interval = Amount1; int bwidth = Amount2; int aalevel = Amount3; int angle = Amount4; if (Amount5 == false) { PrimaryColor = Amount6; PrimaryColor.A = (byte)(Amount7); } //modifying my (x + y) % interval 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 (angle <= 45 || (angle > 135 && angle < 225) || angle > 315) { yfactor = Math.Tan(angle * (3.14159 / 180)); } else { xfactor = 1 / Math.Tan(angle * (3.14159 / 180)); } for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { 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 + interval * 1000000; } double modular = testnum % interval; //if modular < thickness if (modular < bwidth) { 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 { double alpha = (double)(PrimaryColor.A); CurrentPixel = multiplyRGB(CurrentPixel, PrimaryColor, alpha, 255); //if PrimaryColor.A < 255, multiply colors CurrentPixel.A = (byte)(multiplyAlpha((int)(CurrentPixel.A), (int)(alpha))); //if CurrentPixel.A < 255 and PrimaryColor.A < 255 } } else if (aalevel > 0) { //if pixel is beside the line, we do our antialias operation if (modular <= bwidth + 1 || modular >= interval - 1) { double factor = 0; if (modular >= interval - 1) { factor = 1 - (modular - interval + 1); } else { factor = 1 - (bwidth - modular + 1); } //hacks to get around special angles if (angle == 45) { factor += 0.8; } else if (angle == 90) { factor = 0; } else if (angle == 135) { factor -= 0.7; } //our antialias routine double mul = (double)((10 - aalevel) * factor); double div = mul + 1; double alpha = (double)(PrimaryColor.A); ColorBgra tempPixel = new ColorBgra(); tempPixel = multiplyRGB(CurrentPixel, PrimaryColor, 1, div); //Antialias pixel by factor CurrentPixel = multiplyRGB(CurrentPixel, tempPixel, (double)(PrimaryColor.A), 255); //if PrimaryColor.A < 255, multiply colors CurrentPixel.A = (byte)(multiplyAlpha((int)(CurrentPixel.A), (int)(alpha/div))); //if CurrentPixel.A < 255, multiply alpha } } //and we are done dst[x, y] = CurrentPixel; } } } Enjoy! Update1: added brushwidth slide bar. Update2: added antialias level & menu icon. Update3: fixed transparency bug. Update4: added angle slide bar. Update5: added colorwheel, alpha slide bar, fixed more transparency issues Edited October 7, 2018 by toe_head2001 Formatting Quote Some links: | Personal Website | Alien Attack | Try out my plugins: | Antialias | Diagonal Lines | Link to comment Share on other sites More sharing options...
vobie Posted August 20, 2007 Share Posted August 20, 2007 well... you could just use the fill patterns to make diagonal lines Quote Link to comment Share on other sites More sharing options...
jsonchiu Posted August 20, 2007 Author Share Posted August 20, 2007 Yeah, but this plugin take options like brush width and exact amount of pixels between lines. :wink: Quote Some links: | Personal Website | Alien Attack | Try out my plugins: | Antialias | Diagonal Lines | Link to comment Share on other sites More sharing options...
Rec Posted August 20, 2007 Share Posted August 20, 2007 nice plug in I was tired of making them the long way lol Quote Rec. Link to comment Share on other sites More sharing options...
lestat2000_vamp Posted August 20, 2007 Share Posted August 20, 2007 nice one boss. Quote Link to comment Share on other sites More sharing options...
vobie Posted August 20, 2007 Share Posted August 20, 2007 Ahhh, cool. Thanks for clarifying. Quote Link to comment Share on other sites More sharing options...
Gladi8or2 Posted August 20, 2007 Share Posted August 20, 2007 Personaly, I don't like the fact that it uses the brushwidth. I would prefer an extra slider to choose the width. Otherwise you always have to think about changing the width before starting the effect... But, nice job! Quote Link to comment Share on other sites More sharing options...
Helio Posted August 20, 2007 Share Posted August 20, 2007 Thank you! I have wanted this for quite a while! Quote v An excellent open–source strategy game—highly recommended. "I wish I had never been born," she said. "What are we born for?" "For infinite happiness," said the Spirit. "You can step out into it at any moment..." Link to comment Share on other sites More sharing options...
jsonchiu Posted August 20, 2007 Author Share Posted August 20, 2007 Added brush width slide bar. Quote Some links: | Personal Website | Alien Attack | Try out my plugins: | Antialias | Diagonal Lines | Link to comment Share on other sites More sharing options...
LilRedneck Posted August 20, 2007 Share Posted August 20, 2007 nice update Quote omg please dont click thi... Link to comment Share on other sites More sharing options...
Gladi8or2 Posted August 20, 2007 Share Posted August 20, 2007 Added brush width slide bar. Woohoo! Thanks! Quote Link to comment Share on other sites More sharing options...
Myrddin Posted August 20, 2007 Share Posted August 20, 2007 Funky plugin, thanks jsonchiu . I do have a suggestion though, could an anti-aliasing option and a menu icon be added? Nothing serious, though and so far it's working like a charm. Thanks again. Quote How to Save Your Images under Different File Types My dA Gallery Link to comment Share on other sites More sharing options...
Revenant Posted August 20, 2007 Share Posted August 20, 2007 very nice i can see this coming in handy Quote What is life but a game that we play? Link to comment Share on other sites More sharing options...
Bob Posted August 20, 2007 Share Posted August 20, 2007 Yeah, but this plugin take options like brush width and exact amount of pixels between lines. :wink: Neat. Quote No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio Link to comment Share on other sites More sharing options...
jsonchiu Posted August 20, 2007 Author Share Posted August 20, 2007 Added "Antialias Level" option and a simple menu icon Quote Some links: | Personal Website | Alien Attack | Try out my plugins: | Antialias | Diagonal Lines | Link to comment Share on other sites More sharing options...
Myrddin Posted August 20, 2007 Share Posted August 20, 2007 Thanks a lot, jsonchiu, very much appreciated. Quote How to Save Your Images under Different File Types My dA Gallery Link to comment Share on other sites More sharing options...
blooper101 Posted August 20, 2007 Share Posted August 20, 2007 Nooooez! Another plug-in in the "Effect" section! *Faints* Please put it under Render. Apart from that, awesome plug-in! Did you use BoltBait's scanline source code for it? Quote Link to comment Share on other sites More sharing options...
jsonchiu Posted August 20, 2007 Author Share Posted August 20, 2007 Nooooez! Another plug-in in the "Effect" section! *Faints*Please put it under Render. Done Did you use BoltBait's scanline source code for it? Nope, I wrote the code from scratch. ------------------------------------------------------------------------------- Update: fixed transparency bug. You can now apply the plugin using a semi-transparent brush color and it will multiply the color to the background just like what it does when you use the line/curve tool. Quote Some links: | Personal Website | Alien Attack | Try out my plugins: | Antialias | Diagonal Lines | Link to comment Share on other sites More sharing options...
The_Lionhearted Posted August 20, 2007 Share Posted August 20, 2007 Ah jsonchiu...you are awesome! I looked at your site and immediately developed an inferiority complex... Thanks for the plugin! Quote My Gallery Link to comment Share on other sites More sharing options...
snospmiS Posted August 21, 2007 Share Posted August 21, 2007 really cool! especially for userbar-makers Quote .::[ Kiosk Orbs ]::. Link to comment Share on other sites More sharing options...
Paint Boy Posted August 23, 2007 Share Posted August 23, 2007 This is very useful! Thank you another great plugin! I now have all your plugins Quote Link to comment Share on other sites More sharing options...
Mr Frojo Posted August 23, 2007 Share Posted August 23, 2007 I really wish I had something like this a week ago. Instead, I had to do all the lines by hand with the line tool, which took about 5 minutes, and way not accurate at all with spacing. Ill certanly be using this a ton in the future. Thanks! Quote I'm still alive! Link to comment Share on other sites More sharing options...
FirePheonix Posted August 24, 2007 Share Posted August 24, 2007 OMG! THIS IS EXACTLY WHAT I'VE BEEN LOOKING FOR! Thank you!!! Quote Hey! Check this out>>> [my site] Link to comment Share on other sites More sharing options...
Enormator Posted August 24, 2007 Share Posted August 24, 2007 I can't see a direct use for it for me. Could someone please post something, he/she made with it for giving an idea of what to use it for? Quote :Link: website Link to comment Share on other sites More sharing options...
Myrddin Posted August 24, 2007 Share Posted August 24, 2007 snospmiS's userbars (in his signature) and my userbar (in my signature). Then there's LiquidCore's signature which uses diagonal lines, whether with this plugin or not is beside the point. Diagonal lines in general can be used for anything just like Clouds, Gaussian blur or even your Centre Lines plugin, it's all a case of application. Quote How to Save Your Images under Different File Types My dA Gallery 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.