Foxxey Posted May 8, 2020 Share Posted May 8, 2020 (edited) Its a simple plugin that generates, well, a circle! Also it has some extra features 😉 To install it extract the zip file and execute the .bat file. To install it manually drag and drop the .dll file into your Effects folder. Location: Effects>Render CircleGen.cs CircleGen.zip Edited July 20, 2020 by Foxxey 1 2 Quote Link to comment Share on other sites More sharing options...
Foxxey Posted May 8, 2020 Author Share Posted May 8, 2020 Plugin used: CircleGen, EdgeExpander Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted May 8, 2020 Share Posted May 8, 2020 You really need to provide a better description when publishing plugins. Some example images, and a UI screenshot is good too. Where did you get this code from? It looks very old; especially the ColorBgra casts. This code won't even compile with Paint.NET v4.2.11+ Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); int CenterX = ((selection.Right - selection.Left) / 2)+selection.Left; int CenterY = ((selection.Bottom - selection.Top) / 2)+selection.Top; ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; Why are your X,Y loops using selection instead of rect? That can cause serious performance issues. for (int y = selection.Top; y < selection.Bottom; y++) { if (IsCancelRequested) return; int rnd = 0; if (onlyy) rnd = RandomNumber.Next(Min,Max); for (int x = selection.Left; x < selection.Right; x++) { Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Foxxey Posted May 8, 2020 Author Share Posted May 8, 2020 (edited) 9 minutes ago, toe_head2001 said: You really need to provide a better description when publishing plugins. Some example images, and a UI screenshot is good too. Where did you get this code from? It looks very old; especially the ColorBgra casts. This code won't even compile with Paint.NET v4.2.11+ Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); int CenterX = ((selection.Right - selection.Left) / 2)+selection.Left; int CenterY = ((selection.Bottom - selection.Top) / 2)+selection.Top; ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; Why are your X,Y loops using selection instead of rect? That can cause serious performance issues. for (int y = selection.Top; y < selection.Bottom; y++) { if (IsCancelRequested) return; int rnd = 0; if (onlyy) rnd = RandomNumber.Next(Min,Max); for (int x = selection.Left; x < selection.Right; x++) { I didnt use the rect cause it causes rectangle aborts in the random noice thingy. I use the code from BoltBait's website. I am new to C# and coding plugins. So what exactly should i change to what? Edited May 8, 2020 by Foxxey Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted May 8, 2020 Share Posted May 8, 2020 3 minutes ago, Foxxey said: I didnt used the rectangle cause it causes rectangle aborts in the random noice thingi. There's a solution for that. Please use the 'Legacy ROI' option, and switch from selection back to rect. 6 minutes ago, Foxxey said: I use the code from BoltBaits website. I am new to C# and coding plugins. So what exactly should i change to what? Use the code that CodeLab gives you. The example on BoltBait's site are a bit outdated. Here's the newer snippet, as displayed by CodeLab: Rectangle selection = EnvironmentParameters.SelectionBounds; int CenterX = ((selection.Right - selection.Left) / 2) + selection.Left; int CenterY = ((selection.Bottom - selection.Top) / 2) + selection.Top; ColorBgra PrimaryColor = EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Foxxey Posted May 8, 2020 Author Share Posted May 8, 2020 1 minute ago, toe_head2001 said: There's a solution for that. Please use the 'Legacy ROI' option, and switch from selection back to rect. Use the code that CodeLab gives you. The example on BoltBait's site are a bit outdated. Here's the newer snippet, as displayed by CodeLab: Rectangle selection = EnvironmentParameters.SelectionBounds; int CenterX = ((selection.Right - selection.Left) / 2) + selection.Left; int CenterY = ((selection.Bottom - selection.Top) / 2) + selection.Top; ColorBgra PrimaryColor = EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; ok tyvm Quote Link to comment Share on other sites More sharing options...
Foxxey Posted May 8, 2020 Author Share Posted May 8, 2020 15 minutes ago, toe_head2001 said: There's a solution for that. Please use the 'Legacy ROI' option, and switch from selection back to rect. Use the code that CodeLab gives you. The example on BoltBait's site are a bit outdated. Here's the newer snippet, as displayed by CodeLab: Rectangle selection = EnvironmentParameters.SelectionBounds; int CenterX = ((selection.Right - selection.Left) / 2) + selection.Left; int CenterY = ((selection.Bottom - selection.Top) / 2) + selection.Top; ColorBgra PrimaryColor = EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; i just edited the code. it should be fine now. Quote Link to comment Share on other sites More sharing options...
Foxxey Posted May 8, 2020 Author Share Posted May 8, 2020 37 minutes ago, toe_head2001 said: You really need to provide a better description when publishing plugins. Some example images, and a UI screenshot is good too. Where did you get this code from? It looks very old; especially the ColorBgra casts. This code won't even compile with Paint.NET v4.2.11+ Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); int CenterX = ((selection.Right - selection.Left) / 2)+selection.Left; int CenterY = ((selection.Bottom - selection.Top) / 2)+selection.Top; ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; Why are your X,Y loops using selection instead of rect? That can cause serious performance issues. for (int y = selection.Top; y < selection.Bottom; y++) { if (IsCancelRequested) return; int rnd = 0; if (onlyy) rnd = RandomNumber.Next(Min,Max); for (int x = selection.Left; x < selection.Right; x++) { So i tried doing the same for my plugin SoundWave and its bugged now. its generating a new random wave height for each rect. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted May 8, 2020 Share Posted May 8, 2020 Yes, 'Legacy ROI' uses small horizontal strips the rect, so it won't well for the wave plugin. For that plugin, you may want to utilize the PreRender() method in CodeLab. Let me see if I can find a good explanation for PreRender() ... Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Eli Posted May 8, 2020 Share Posted May 8, 2020 Hi @Foxxey, I have an error. Spoiler File: C:\Program Files\paint.net\Effects\CircleGen.dll Name: CircleGenEffect.CircleGenEffectPlugin Version: 1.1.7433.27416 Author: Copyright ©2020 by Foxxey Copyright: Renders a Circle (+Extra Features) Website: https://www.getpaint.net/redirect/plugins.html Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.ArgumentOutOfRangeException: 'minValue' cannot be greater than maxValue. Parameter name: minValue at System.Random.Next(Int32 minValue, Int32 maxValue) at CircleGenEffect.CircleGenEffectPlugin.Render(Surface dst, Surface src, Rectangle rect) at CircleGenEffect.CircleGenEffectPlugin.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length) at PaintDotNet.Effects.Effect`1.Render(Rectangle[] renderRects, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 55 at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 98 at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, RectInt32[] rois, Result`1 lazyClipMaskRenderer) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 193 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 171 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 164 at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 277 --- End of inner exception stack trace --- at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 458 at PaintDotNet.Effects.BackgroundEffectRenderer.Abort() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 413 at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClass43_5.<RunEffectImpl>b__7() in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 990 Quote Link to comment Share on other sites More sharing options...
Foxxey Posted May 8, 2020 Author Share Posted May 8, 2020 (edited) ok i look into it Edited May 8, 2020 by Foxxey Quote Link to comment Share on other sites More sharing options...
Foxxey Posted May 8, 2020 Author Share Posted May 8, 2020 @Eli'minValue' cannot be greater than maxValue Quote Link to comment Share on other sites More sharing options...
ReMake Posted May 8, 2020 Share Posted May 8, 2020 56 minutes ago, Foxxey said: @Eli'minValue' cannot be greater than maxValue Yes, the IdirectUI Rule 'LinkValuesBasedOnBooleanRule' would be useful in this case, but you will need to compile the effect in VisualStudio. 2 Quote Link to comment Share on other sites More sharing options...
Foxxey Posted July 19, 2020 Author Share Posted July 19, 2020 On 5/8/2020 at 5:17 PM, Eli said: Hi @Foxxey, I have an error. Reveal hidden contents File: C:\Program Files\paint.net\Effects\CircleGen.dll Name: CircleGenEffect.CircleGenEffectPlugin Version: 1.1.7433.27416 Author: Copyright ©2020 by Foxxey Copyright: Renders a Circle (+Extra Features) Website: https://www.getpaint.net/redirect/plugins.html Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.ArgumentOutOfRangeException: 'minValue' cannot be greater than maxValue. Parameter name: minValue at System.Random.Next(Int32 minValue, Int32 maxValue) at CircleGenEffect.CircleGenEffectPlugin.Render(Surface dst, Surface src, Rectangle rect) at CircleGenEffect.CircleGenEffectPlugin.OnRender(Rectangle[] rois, Int32 startIndex, Int32 length) at PaintDotNet.Effects.Effect`1.Render(Rectangle[] renderRects, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 55 at PaintDotNet.Effects.Effect`1.Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, Int32 startIndex, Int32 length) in D:\src\pdn\src\Effects\Effect`1.cs:line 98 at PaintDotNet.Effects.BackgroundEffectRenderer.RenderWithClipMask(Effect effect, EffectConfigToken token, RenderArgs dstArgs, RenderArgs srcArgs, RectInt32[] rois, Result`1 lazyClipMaskRenderer) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 193 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderTile(EffectConfigToken token, Int32 tileIndex) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 171 at PaintDotNet.Effects.BackgroundEffectRenderer.RendererContext.RenderNextTile(EffectConfigToken token) in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 164 at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 277 --- End of inner exception stack trace --- at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 458 at PaintDotNet.Effects.BackgroundEffectRenderer.Abort() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 413 at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClass43_5.<RunEffectImpl>b__7() in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 990 I remade the UI so this shouldn't be an issue anymore 1 1 Quote Link to comment Share on other sites More sharing options...
Eli Posted July 19, 2020 Share Posted July 19, 2020 9 hours ago, Foxxey said: I remade the UI so this shouldn't be an issue anymore Thanks @Foxxey, It works pretty well now. 1 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.