VeLC Posted April 18, 2022 Share Posted April 18, 2022 (edited) Draws text along an arc This is basically dpy's Circle Text plugin with a different UI and better math for proportional fonts Also in Effects > Text Formations Versions: 1.0(20220418) - Initial Release 1.1(20220420) - Now works with selection and slightly shorter UI 1.2(20220421) - Update code to make it compatible with CodeLab v6.1 (and below?). Also, detects if user canceled. 1.3(20220428) - Now works faster if there are multiple selections 1.4(20220506) - Fix space character not rendering when Character Spacing is zero and slightly shorter UI 1.5(20220513) - Code Update and slightly shorter UI CodeLab Code License: LPGL-3.0 Spoiler // Name: Arc Text // Submenu: Text Formations // Author: Louie Velarde // Title: Arc Text // Version: 1.5 // Desc: Draws text along an arc // Keywords: arc text|circle text|circular text // URL: https://forums.getpaint.net/topic/119904-arc-text/ // Help: https://forums.getpaint.net/topic/119904-arc-text/ // Force Single Render Call #region UICode TextboxControl text = ""; // [3600] IntSliderControl repeat = 1; // [1,360] Repeat FontFamily fontFamily = new FontFamily("Arial"); // IntSliderControl fontSize = 12; // [8,288] CheckboxControl bold = false; // Bold PanSliderControl center = Pair.Create(0.000, 0.000); // Center ListBoxControl alignment = 0; // |Start Position|Center Position|End Position AngleControl position = 135; // [0,360] CheckboxControl clockwise = true; // Clockwise CheckboxControl useAngle = true; // Calculate character spacing based on arc angle CheckboxControl endSpace = false; // Append space after last character IntSliderControl charSpacing = 0; // [0,100] {!useAngle} Character Spacing IntSliderControl angle = 90; // [0,360] {useAngle} Arc Angle IntSliderControl radius = 150; // [1,1000] Arc Radius #endregion bool rendered; void PreRender(Surface dst, Surface src) { rendered = false; } void Render(Surface dst, Surface src, Rectangle rect) { if (rendered) return; rendered = true; rect = EnvironmentParameters.SelectionBounds; dst.CopySurface(src, rect.Location, rect); if (text == string.Empty) return; StringBuilder line = new StringBuilder(text); for (int i = 2; i <= repeat; ++i) { if (IsCancelRequested) return; line.Append(text); } using (Graphics g = new RenderArgs(dst).Graphics) using (Region gClipRegion = new Region(rect)) using (Font font = new Font(fontFamily, fontSize, bold ? FontStyle.Bold : FontStyle.Regular)) using (Brush brush = new SolidBrush(EnvironmentParameters.PrimaryColor)) { g.Clip = gClipRegion; g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; double translateX = rect.Left + (center.First + 1) / 2 * rect.Width; double translateY = rect.Top + (center.Second + 1) / 2 * rect.Height; g.TranslateTransform((float) translateX, (float) translateY); StringFormat format = new StringFormat(StringFormat.GenericTypographic); format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; format.FormatFlags |= StringFormatFlags.NoFontFallback; SizeF[] sizes = new SizeF[line.Length]; double totalWidths = 0; double totalHeights = 0; for (int i = 0; i < line.Length; ++i) { if (IsCancelRequested) return; sizes[i] = g.MeasureString(line[i].ToString(), font, short.MaxValue, format); totalWidths += sizes[i].Width; totalHeights += sizes[i].Height; } double height = totalHeights / line.Length; double arcLength; if (useAngle) { arcLength = Math.PI * radius * angle / 180; } else { arcLength = totalWidths + charSpacing * (line.Length - 1); if (endSpace) arcLength += charSpacing; } double arcAngle = arcLength * 180 / Math.PI / radius; double spaceLength = (arcLength - totalWidths) / (line.Length - (endSpace ? 0 : 1)); double spaceAngle = spaceLength * 180 / Math.PI / radius; int s = clockwise ? 1 : -1; switch (alignment) { case 0: g.RotateTransform((float) (s * 90 - position)); break; case 1: g.RotateTransform((float) (s * 90 - position - s * arcAngle / 2)); break; case 2: g.RotateTransform((float) (s * 90 - position - s * arcAngle)); break; } double halfCharAngle = sizes[0].Width * s * 90 / Math.PI / radius; g.RotateTransform((float) (halfCharAngle)); float y = (float) (clockwise ? -radius : radius - height); g.DrawString(line[0].ToString(), font, brush, sizes[0].Width / -2, y, format); for (int i = 1; i < line.Length; ++i) { if (IsCancelRequested) return; g.RotateTransform((float) (halfCharAngle + s * spaceAngle)); halfCharAngle = sizes[i].Width * s * 90 / Math.PI / radius; g.RotateTransform((float) (halfCharAngle)); g.DrawString(line[i].ToString(), font, brush, sizes[i].Width / -2, y, format); } } } ArcText.zip Edited May 13, 2022 by VeLC Version 1.5 6 3 Quote Link to comment Share on other sites More sharing options...
Panchdara Posted April 18, 2022 Share Posted April 18, 2022 (edited) Thanks! Question though. I see that in your ArcText.zip file the velc.ArcText.dll has file size 15872 and the install batch file has size 2842. I copied your code and placed in CodeLab and built the effect to ArcText.zip (on my desktop) and see the file sizes have changed to ArcText.dll == 15360 and the install batch file to 2832. Is there any reason? Is it due to .NET call differences? (version 6.0.3)?? Just asking. Works though. 👍 edit: figured the batch file sizes (velc.) Edited April 18, 2022 by Panchdara Quote Link to comment Share on other sites More sharing options...
otuncelli Posted April 18, 2022 Share Posted April 18, 2022 11 hours ago, Panchdara said: I copied your code and placed in CodeLab and built the effect to ArcText.zip (on my desktop) and see the file sizes have changed to ArcText.dll == 15360 Probably the lack of window icon causes a smaller file. Quote Link to comment Share on other sites More sharing options...
Panchdara Posted April 19, 2022 Share Posted April 19, 2022 7 hours ago, otuncelli said: Probably the lack of window icon causes a smaller file. 👍👍 Quote Link to comment Share on other sites More sharing options...
VeLC Posted April 20, 2022 Author Share Posted April 20, 2022 Version 1.1 - Now works with selection and slightly shorter UI 2 1 Quote Link to comment Share on other sites More sharing options...
NSD Posted April 20, 2022 Share Posted April 20, 2022 If Repeat>1 the text disappears. I used another variable (txt) to make it work. (CodeLab v6.1) StringBuilder sb = new StringBuilder(text); for (int i = 2; i <= repeat; ++i) { sb.Append(text); } string txt = sb.ToString(); Quote Link to comment Share on other sites More sharing options...
VeLC Posted April 21, 2022 Author Share Posted April 21, 2022 Version 1.2 - Update code to make it compatible with CodeLab v6.1 (and below?). Also, detects if user canceled. 1 1 1 Quote Link to comment Share on other sites More sharing options...
VCS Posted April 22, 2022 Share Posted April 22, 2022 how do i install the plugin like circle text to paint.net? can any one please help Quote Link to comment Share on other sites More sharing options...
Rle Posted April 22, 2022 Share Posted April 22, 2022 👓https://forums.getpaint.net/topic/1708-how-to-install-pluginsgeneral-plugin-troubleshooting-thread/ Quote Link to comment Share on other sites More sharing options...
homebrew Posted April 25, 2022 Share Posted April 25, 2022 how many separate text tools do we got? circle; circular and others. maybe we can agree on something Quote Link to comment Share on other sites More sharing options...
BoltBait Posted April 25, 2022 Share Posted April 25, 2022 29 minutes ago, homebrew said: how many separate text tools do we got? circle; circular and others. maybe we can agree on something Just use the one you like and don't bother installing the rest. 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
VeLC Posted April 28, 2022 Author Share Posted April 28, 2022 Version 1.3 - Now works faster if there are multiple selections 3 1 Quote Link to comment Share on other sites More sharing options...
VeLC Posted May 6, 2022 Author Share Posted May 6, 2022 Version 1.4 - Fix space character not rendering when Character Spacing is zero and slightly shorter UI 3 Quote Link to comment Share on other sites More sharing options...
VeLC Posted May 13, 2022 Author Share Posted May 13, 2022 Version 1.5 - Code Update and slightly shorter UI 1 1 1 Quote Link to comment Share on other sites More sharing options...
TheBlakeBox Posted June 26, 2022 Share Posted June 26, 2022 Is there any reason that command prompt tries open when I open the file? Seems pretty suspicious but let me know if there is a reason. Quote Link to comment Share on other sites More sharing options...
mimccravey Posted yesterday at 01:43 AM Share Posted yesterday at 01:43 AM This is great for a top rocker, but what about a bottom rocker where the ends are curved up? I want to do two lines of text; one on the top curved down and one on the bottom curved up. Is there a plugin for that? Quote Link to comment Share on other sites More sharing options...
AndrewDavid Posted yesterday at 01:53 AM Share Posted yesterday at 01:53 AM @mimccravey Welcome to the forum. Have a look at this one. Quote (My New Signature) Nickpic was a image hosting source made specifically for RPers and its shutting down. I use postimage.IO for free web hosting. How long before they follow photobucket and NicKPic? Link to comment Share on other sites More sharing options...
Pixey Posted 15 hours ago Share Posted 15 hours ago And there is also this Plugin here. Quote How I made Jennifer & Halle in Paint.net My Gallery | My Deviant Art "Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon. Link to comment Share on other sites More sharing options...
AndrewDavid Posted 12 hours ago Share Posted 12 hours ago @Pixey Do you see what you did? Pointing to yourself? Codelab now rejects the posted CS script with 4 errors. Could someone take the time to correct it please? I did half. double translateX = rect.Left + (center.First + 1) / 2 * rect.Width; double translateY = rect.Top + (center.Second + 1) / 2 * rect.Height; These posted scripts are valuable lessons to demonstrate plugin development. Quote (My New Signature) Nickpic was a image hosting source made specifically for RPers and its shutting down. I use postimage.IO for free web hosting. How long before they follow photobucket and NicKPic? Link to comment Share on other sites More sharing options...
Pixey Posted 11 hours ago Share Posted 11 hours ago 37 minutes ago, AndrewDavid said: Do you see what you did? Pointing to yourself? 😁 Silly me - I was jumping between posts and didn't notice 😂 Quote How I made Jennifer & Halle in Paint.net My Gallery | My Deviant Art "Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon. 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.