BoltBait Posted July 9 Share Posted July 9 Label Maker v1.0 I remember having one of these when I was a kid: This plugin is basically the same thing... This plugin is made from this request: https://forums.getpaint.net/topic/127977-suggestion-insert-text-with-color-in-background/ Download LabelMaker.zip Run the included bat file to install. Once installed, it will show up under Effects > Text Formations > Label Maker. Source Code Spoiler // Name: Label Maker // Submenu: Text Formations // Author: BoltBait // Title: BoltBait's Label Maker v1.1 // Version: 1.1 // Desc: Render text on a colored background // Keywords: text|render|labels|maker // URL: https://BoltBait.com/pdn #region UICode TextboxControl Amount1 = ""; // [255] Text FontFamily Amount2 = "Courier New"; // Font IntSliderControl Amount6 = 72; // [10,200] Size ColorWheelControl Amount3 = ColorBgra.FromBgr(0, 0, 0); // [PrimaryColor!] Text Color ColorWheelControl Amount4 = ColorBgra.FromBgr(255, 255, 255); // [SecondaryColor!] Background Color PanSliderControl Amount5 = new Vector2Double(0.000, 0.980); // Location CheckboxControl Amount7 = false; // Add box outline ColorWheelControl Amount8 = ColorBgra.FromBgr(0, 0, 0); // [Black] {Amount7} Box outline IntSliderControl Amount9 = 2; // [1,20] Outline size #endregion protected override unsafe void OnDraw(IDeviceContext deviceContext) { string myText = " " + Amount1.Trim() + " "; // Maintain background deviceContext.DrawImage(Environment.SourceImage); // Get the size of our canvas RectFloat sourceBounds = new RectFloat(Point2Float.Zero, Environment.Document.Size); // Create a brush for text and a brush for the background // Whenever using the color out of a color wheel control, you must double cast it otherwise you'll get // the wrong shade of color. ISolidColorBrush solidFillBrush = deviceContext.CreateSolidColorBrush((LinearColorA)(SrgbColorA)Amount3); ISolidColorBrush backgroundBrush = deviceContext.CreateSolidColorBrush((LinearColorA)(SrgbColorA)Amount4); ISolidColorBrush outlineBrush = deviceContext.CreateSolidColorBrush((LinearColorA)(SrgbColorA)Amount8); // Set the antialiasing modes deviceContext.AntialiasMode = AntialiasMode.PerPrimitive; deviceContext.TextAntialiasMode = TextAntialiasMode.Grayscale; // Set the text rendering mode deviceContext.UseTextRenderingMode(TextRenderingMode.Outline); // Prepare for rendering text IDirectWriteFactory textFactory = this.Services.GetService<IDirectWriteFactory>(); IGdiFontMap fm = textFactory.GetGdiFontMap(); // Select your font to look at the font properties FontProperties fp = fm.TryGetFontProperties(Amount2); // Use your font properties to create an actual font ITextFormat textFormat = textFactory.CreateTextFormat( fp.FontFamilyName, // font family name null, FontWeight.Bold, // font weight FontStyle.Normal, // font style fp.Stretch, // how to stretch the font Amount6); // size in points // Combine your text with your text format to create a layout ITextLayout textLayout = textFactory.CreateTextLayout( myText, textFormat, TextLayoutConstants.DefaultMaxWidth, TextLayoutConstants.DefaultMaxHeight); // Measure the text we're going to render TextMeasurement tm = textLayout.Measure(); // Make a rectangle of the background strip we're going to color in RectFloat r = new RectFloat(sourceBounds.Center.X - (tm.Width/2), sourceBounds.Center.Y - (tm.Height/2), tm.Width, tm.Height); // Calculate the difference in location based on the [+] control float xoffset = r.X * (float)Amount5.X; float yoffset = r.Y * (float)Amount5.Y; // Here we always offset all drawing by 0.5f (half a pixel) to get cleaner renders // as this draws on pixel boundaries instead of between them. using (deviceContext.UseTranslateTransform(xoffset + 0.5f, yoffset + 0.5f)) { if (Amount7) { // Draw the background rectangle deviceContext.DrawRectangle(r, outlineBrush, Amount9*2); } // Draw the background rectangle deviceContext.FillRectangle(r, backgroundBrush); // Draw the text deviceContext.DrawText( myText, // the actual text to render textFormat, // format of text defined above r, // text location solidFillBrush, // our brush, from above DrawTextOptions.None); // Options } } Enjoy! 3 6 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted July 10 Share Posted July 10 Woooohooo! A new plugin! Thanks for this @BoltBait, and many thanks also for the annotated source code 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 July 10 Author Share Posted July 10 2 hours ago, Ego Eram Reputo said: many thanks also for the annotated source code You're welcome! I just edited in a few more comments... little tricks and tips on how to write a plugin. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
BlastOfBN Posted July 10 Share Posted July 10 Simple, but could come in handy one of these days. By the way, is that your chair? ( ͡° ͜ʖ ͡°) Quote Link to comment Share on other sites More sharing options...
ReMake Posted July 10 Share Posted July 10 @BoltBait, have you compiled the effect in CodeLab? Quote Link to comment Share on other sites More sharing options...
BoltBait Posted July 10 Author Share Posted July 10 6 minutes ago, ReMake said: @BoltBait, have you compiled the effect in CodeLab? Yes, I used Paint.NET v5.0.13 (latest stable release) and CodeLab v6.12. I assume you've tried building it with PdN 5.1... @Rick Brewster has made some changes to PdN that break CodeLab in this area and this script won't build. Rick is actively working on designing/coding some changes in this area and when he's done making it easy for plugin authors, I will support those changes in a new version of CodeLab. Until then, just use the latest stable build. 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
BoltBait Posted July 10 Author Share Posted July 10 19 minutes ago, BlastOfBN said: is that your chair? Yes. I ❤️ my chair! One of the best investments I've ever made. I use it every single day. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
ReMake Posted July 10 Share Posted July 10 1 minute ago, BoltBait said: I assume you've tried building it with PdN 5.1... Yes. Thanks for the clarification. Quote Link to comment Share on other sites More sharing options...
Tactilis Posted July 10 Share Posted July 10 Your Label Maker plugin is adding labels in unexpected places! 😉 2 Quote Link to comment Share on other sites More sharing options...
Jechome Posted August 9 Share Posted August 9 Does this plugin do outlines around the text box (just wondering). 1 Quote Deviantart Gallery: https://www.deviantart.com/shaminchi Link to comment Share on other sites More sharing options...
BoltBait Posted August 9 Author Share Posted August 9 55 minutes ago, Jechome said: Does this plugin do outlines around the text box (just wondering). No, but that’s something that could be added. 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
lynxster4 Posted August 10 Share Posted August 10 I vote for added outlines @BoltBait. I was going to ask for this earlier but didn't. Quote My Art Gallery | My Shape Packs | ShapeMaker Mini Tut | Air Bubble Stained Glass Chrome Text with Reflections | Porcelain Text w/ Variegated Coloring | Realistic Knit PatternOpalescent Stained Glass | Frosted Snowman Cookie | Leather Texture | Plastic Text | Silk Embroidery Visit my Personal Website "Never, ever lose your sense of humor - you'll live longer" Link to comment Share on other sites More sharing options...
Welsh Yellow Cheddar Posted August 18 Share Posted August 18 @BoltBait Thank you, I always have a use for text effects. Quote 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.