Jump to content
How to Install Plugins ×

Circle Generator (CircleGen)


Foxxey

Recommended Posts

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

 

 

Screenshot_6.png

 

 

CircleGen.cs CircleGen.zip

 

 

Edited by Foxxey
  • Like 1
  • Upvote 2
Link to comment
Share on other sites

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++)
    {

 

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

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 by Foxxey
Link to comment
Share on other sites

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.

CodeLabMenu.png.e9f241f990eba6ced65cd213

 

 

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;

 

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

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.

CodeLabMenu.png.e9f241f990eba6ced65cd213

 

 

 

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

Link to comment
Share on other sites

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.

CodeLabMenu.png.e9f241f990eba6ced65cd213

 

 

 

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.

Link to comment
Share on other sites

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.

wave.png

Link to comment
Share on other sites

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() ...

 

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

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
 

 

Link to comment
Share on other sites

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.

  • Upvote 2
Link to comment
Share on other sites

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 

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...