Arbruteblade Posted January 16, 2010 Share Posted January 16, 2010 What's the function(s)? Quote Link to comment Share on other sites More sharing options...
BoltBait Posted January 16, 2010 Share Posted January 16, 2010 It is fairly complicated. I just sent Illnab1024 a message to see if he has some sample code. His AlphaMask plugin has this function. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Arbruteblade Posted January 16, 2010 Share Posted January 16, 2010 While I wait for a reply, I want to say, I love this plugin, I can finally do basic algorithms without pixel-by-pixel edits, keep up the good work Quote Link to comment Share on other sites More sharing options...
Illnab1024 Posted January 17, 2010 Share Posted January 17, 2010 Also, some fun with networking! A polar distortion based off of an image taken from nik.bot.nu (advice: slightly maybe NSFW). Supposedly, this HSV algorithm works. I'm too tired to try to understand it atm, so I just threw it in there. It works I suppose. (takes a while to do everything, I think cause of several requests gone by without caching) #region UICode int Amount1=10; //[0,300]Distortion length #endregion void Render(Surface dst, Surface src, Rectangle rect) { Surface img = nikbotImg; float[] vector = new float[2]{0,0}; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { vector = calVector(x,y); dst[x,y] = src.GetBilinearSampleWrapped(x+vector[0],y+vector[1]); } } } static string nikbotBrowseUri = "http://nik.bot.nu/browse.fu?cnt=1&pn=0&srt=7&eq=0&rs=0&rt=0&da=7&nw=0"; string imgUri = "http://nik.bot.nu/img/"; string imgName; Surface nikbotImg { get { if(_nikbotImg == null) { getImage(); return _nikbotImg; } return _nikbotImg; } } Surface _nikbotImg = null; double[] HSVcolor(byte r, byte g, byte { double[] a; double R = r/255d, G = g/255d, B = b/255d, v, x, f; int i; x = min(R, G, ; v = max(R, G, ; if(v == x) return new double[3]{0, 0, v}; f = (R == x) ? G - B : ((G == x) ? B - R : R - G); i = (R == x) ? 3 : ((G == x) ? 5 : 1); a = new double[3]{i - f /(v - x), (v - x)/v, v}; a[0] = a[0]*((2*Math.PI)/6d); return a; } double min(double a,double b,double c) { a = Math.Min(a,; return Math.Min(a,c); } double max(double a,double b,double c) { a = Math.Max(a,; return Math.Max(a,c); } float[] calVector(int x,int y) { ColorBgra p = nikbotImg[x,y]; float[] vectorrrrr = new float[2]{0,0}; double[] HSVal = HSVcolor(p.R, p.G, p.; double length, direction; length = HSVal[1]*HSVal[2]*(Amount1); direction = HSVal[0]; // Shud be radians, I hope. vectorrrrr[0] = (float)(Math.Sin(direction)*length); vectorrrrr[1] = (float)(Math.Cos(direction)*length); return vectorrrrr; } void getImage() { System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(nikbotBrowseUri); string resultPage = string.Empty; using (System.Net.HttpWebResponse httpWebResponse = (System.Net.HttpWebResponse)request.GetResponse()) { using (System.IO.Stream responseStream = httpWebResponse.GetResponseStream()) { using (System.IO.StreamReader reader = new System.IO.StreamReader(responseStream)) { resultPage = reader.ReadToEnd(); } } } int imgIdx = resultPage.IndexOf(" imgIdx += 28; resultPage = resultPage.Remove(0,imgIdx); resultPage = resultPage.Remove(resultPage.IndexOf("\""),resultPage.Length-resultPage.IndexOf("\"")); imgUri += resultPage; Image im = null; try { System.Net.HttpWebRequest request2 = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(imgUri); request2.Method = "GET"; request2.Timeout = 10000; request2.ProtocolVersion = System.Net.HttpVersion.Version11; using (System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request2.GetResponse()) { using (System.IO.Stream responseStream = response.GetResponseStream()) { im = Image.FromStream(responseStream); } } } catch (Exception ex) { MessageBox.Show("Lols, no image for you:"+ex.Message+Environment.NewLine+imgUri); return; } _nikbotImg = Surface.CopyFromBitmap((Bitmap)im); } Oh and by the way, I think this effect is simply amazing. Just, a personal note. Quote ~~ Link to comment Share on other sites More sharing options...
BoltBait Posted March 17, 2010 Share Posted March 17, 2010 CodeLab 1.5 released today. Get the update here: http://www.boltbait.com/pdn/codelab/ I was playing around with text boxes and realized that I had never added the multi-line text box to CodeLab... so I did. Here is a sample script that takes advantage of the new control: // Title: BoltBait's Render Text Sample // Author: BoltBait // Submenu: Render // Name: Text // URL: http://www.BoltBait.com/pdn #region UICode string Amount1 = ""; // [1,32767] Text FontFamily Amount2 = new FontFamily("Arial"); // Font int Amount3 = 12; // [10,72] Size byte Amount4 = 1; // [1] Smoothing|None|Anti-Alias|ClearType ColorBgra Amount5 = ColorBgra.FromBgr(0,0,0); // Color Pair<double, double> Amount6 = Pair.Create( 0.0 , 0.0 ); // Location #endregion void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); // Reset the destination canvas dst.CopySurface(src,rect.Location,rect); // Determine where the text will be written int column = (int)Math.Round(((Amount6.First + 1) / 2) * (selection.Right - selection.Left)); int row = (int)Math.Round(((Amount6.Second + 1) / 2) * (selection.Bottom - selection.Top)); // Create a brush and graphics surface to write on SolidBrush Brush1 = new SolidBrush(Amount5.ToColor()); Graphics g = new RenderArgs(dst).Graphics; // specify smoothing mode switch (Amount4) { case 0: // none g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; break; case 1: // anti-alias g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; break; case 2: // cleartype g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; break; } // Be sure to clip to our ROI g.Clip = new Region(rect); // Create a font from user selection Font SelectedFont; try { SelectedFont = new Font(Amount2.Name, Amount3); } catch { // If font creation fails, use Arial font SelectedFont = new Font("Arial", Amount3); } // Write our text to the canvas g.DrawString(Amount1, SelectedFont, Brush1, column, row); } The code above shows more than just the new multi-line text box, but also how to do font smoothing (or not). Here's what that script builds: Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
dpy Posted March 17, 2010 Share Posted March 17, 2010 nice update. I tried the sample. Thank you . BoltBait Quote my Paint.net site(Japanese)|my Paint.net youtube(Strange English/Japanese) Link to comment Share on other sites More sharing options...
BoltBait Posted April 21, 2010 Share Posted April 21, 2010 I just updated the script above with an example of 3 types of font smoothing (anti-alias, cleartype, and none). Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
MadJik Posted April 24, 2010 Share Posted April 24, 2010 Hi BoltBait, Thanks for this update, I was looking for the lastest version of codelab because I've encounted some trouble I though it could be solved... But it is not (yet). Could it be possible to have a decimal value for the range and the default values when we build the DLL ? PS: I haven't tested the text feature yet but I'll do soon as some ideas are poping in my brain. Regards. Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal Link to comment Share on other sites More sharing options...
BoltBait Posted April 24, 2010 Share Posted April 24, 2010 MadJik, I see the issue and I have sent you a fixed version to test. (However, please note that the Paint.NET controls only go to 2 decimal places. So, 0.01 will work and 0.001 will not.) Let me know if it works for you and I'll make an official release. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
BoltBait Posted August 4, 2010 Share Posted August 4, 2010 CodeLab 1.6 released today. Features: - Float slider bug fix. - Code Completion. (This is similar to Microsoft's Intellisense.) - "File>New" Templates for writing complex effects. Go get it here: http://www.boltbait.com/pdn/CodeLab/ Screenshot: Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Cookies Posted August 5, 2010 Share Posted August 5, 2010 I like the new version and it's Auto Completion but the Auto Completion is buggy, sometimes lets say i wrote "CurrentPixel.R" and then add a comma and press space then there often comes an extra R (Actually haven't tried that yet without being buggy in any way) Quote Link to comment Share on other sites More sharing options...
BoltBait Posted August 5, 2010 Share Posted August 5, 2010 I like the new version and it's Auto Completion but the Auto Completion is buggy, sometimes lets say i wrote "CurrentPixel.R" and then add a comma and press space then there often comes an extra R (Actually haven't tried that yet without being buggy in any way) Press space or Esc, then comma. Once the Auto Completion list is visible, there are only certain keys that will finish the code: Space, Enter, Tab: Replace what is typed with selection Esc: Cancel I'll add comma to the first list in the next build. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
csm725 Posted August 5, 2010 Share Posted August 5, 2010 Impressive. Quote My deviantART | Sig Battles | My Tutorials | csm725.com Click to enter or vote in the official Paint.NET competitions! COMPETITIONS: LOGO OF THE WEEK Link to comment Share on other sites More sharing options...
Cookies Posted August 5, 2010 Share Posted August 5, 2010 Not to be picky but could you also somehow add ')', ';' and other usually used keys and characters to the list and a way to disable the auto completion? Quote Link to comment Share on other sites More sharing options...
BoltBait Posted August 6, 2010 Share Posted August 6, 2010 Yeah. No problem. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
MadJik Posted August 9, 2010 Share Posted August 9, 2010 I'm using french win7 and the autocompletion is activated with ; instead . Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal Link to comment Share on other sites More sharing options...
BoltBait Posted August 9, 2010 Share Posted August 9, 2010 MadJik, here is the code that activates the code completion: if (e.KeyData == Keys.OemPeriod) According to the compiler's help: OemPeriod is defined as "The OEM period key on any country/region keyboard (Windows 2000 or later)." So, I'm not sure why this isn't working. How do you suggest I handle this? Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Cookies Posted September 3, 2010 Share Posted September 3, 2010 (edited) PDN crashed when i wrote private UnaryPixelOps.Desaturate and then pressed space Tried this twice, crashed both times Edited September 3, 2010 by Cookies Quote Link to comment Share on other sites More sharing options...
pyrochild Posted September 3, 2010 Share Posted September 3, 2010 PDN crashed when i wrote private UnaryPixelOps.Desaturate and then pressed space Tried this twice, crashed both times This repros here. Further, after pressing . the IntelliSense box shows up, but nothing in it. EDIT: Typing UnaryPixelOps.[space] anywhere also kills it. Quote ambigram signature by Kemaru [i write plugins and stuff] If you like a post, upvote it! Link to comment Share on other sites More sharing options...
BoltBait Posted September 3, 2010 Share Posted September 3, 2010 Thanks for the report. I'll look into it this weekend when I'm feeling better. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
n d Posted September 7, 2010 Share Posted September 7, 2010 (edited) Doesn't crash for me... the intellisense window is empty though. ..no wait, now it crashed. nvm Edited September 7, 2010 by n d Quote Link to comment Share on other sites More sharing options...
BoltBait Posted September 7, 2010 Share Posted September 7, 2010 Yeah, I had a look at it. I'm not sure why the intellisense window is empty, but that is definately what is causing the problem. When it comes up blank, just press Esc and it should go away and not cause a crash. I wasn't really up to doing any work this past weekend, I'll see what I can do this week. Sorry for the delay. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted November 20, 2010 Share Posted November 20, 2010 Am loving the new Intellisense! A brilliant addition. I can't get Codelab to accept lambda expressions at all . Is it my code or are lambda expressions not compatible/ not implimented? Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
BoltBait Posted November 20, 2010 Share Posted November 20, 2010 Am loving the new Intellisense! A brilliant addition. Thanks, that reminds me that I need to publish an update. I can't get Codelab to accept lambda expressions at all . Is it my code or are lambda expressions not compatible/ not implimented? I'm not sure. Is a reference needed to make them work? If so, I could add it. Just let me know. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted November 20, 2010 Share Posted November 20, 2010 Codelab is not liking the lambda "goes to" => operator. I don't know about a reference, all I know is that they have been included in C# since version 3.0. Func<ColorBgra, byte> Intensity = iColor => (iColor.R + iColor.G + iColor. * iColor.A * iColor.A / 195075; Up til now I've been using functions, but I would like to improve my coding practice Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker 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.