Jump to content

Feature request: Remove rounded rectangle and add value "Rounding radius" to rectangle.


Craftist

Recommended Posts

Hello.

I need to change rounded rectangle's rounding radius.

So could you remove rounded rectangle and add value "Rounding radius" to rectangle please?

 

Thanks for any attention.

Link to comment
Share on other sites

You may want to wait and hear it from the horse's mouth (from Rick), but I'm 99% sure that can't be done with the Shapes tool. As far as I know, the shapes are hard coded, and paint.net simply multiplies on the X axis & the Y axis when you resize it.

 

There are some plugins though. They both have the same name.

Rounded Rectangle

Rounded Rectangle

 

I also wrote a no-frills effect for this not too long ago. It just uses a Bezier Curve to draw the rectangle. You can play with it in CodeLab. Adjust the radius, width, height, color, ect.

Hidden Content: CodeLab Script

 
// Name: Rounded Rect
// Submenu: Render
// Author: toe_head2001
// Title:
// Version: 0.9
// Desc:
// Keywords:
// URL:
// Help:
#region UICode
IntSliderControl Amount1 = 50; // [0,500] Radius
IntSliderControl Amount2 = 400; // [2,1000] Width
IntSliderControl Amount3 = 300; // [2,1000] Height
IntSliderControl Amount4 = 2; // [1,25] Line Width
ColorWheelControl Amount5 = ColorBgra.FromBgr(0,0,0); // [PrimaryColor] Line Color
IntSliderControl Amount6 = 255; // [0,255] 
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    float centerX = ((selection.Right - selection.Left) / 2f) + selection.Left;
    float centerY = ((selection.Bottom - selection.Top) / 2f) + selection.Top;
    float left = centerX - Amount2 / 2f;
    float right = centerX + Amount2 / 2f;
    float top = centerY - Amount3 / 2f;
    float bottom = centerY + Amount3 / 2f;
    float radiusMax = Math.Min(Amount2, Amount3) / 2f;
    float radius = (Amount1 > radiusMax) ? radiusMax : Amount1;
    float radiusNub = radius / 2f;
    
    PointF[] points = new PointF[31];
    points[0] = new PointF(left, top + radius);
    points[1] = new PointF(left, top + radiusNub);
    points[2] = new PointF(left + radiusNub, top);
    points[3] = new PointF(left + radius, top);
    points[4] = new PointF(centerX, top);
    points[5] = new PointF(centerX, top);
    points[6] = new PointF(right - radius, top);
    points[7] = new PointF(right - radiusNub, top);
    points[8] = new PointF(right, top + radiusNub);
    points[9] = new PointF(right, top + radius);
    points[10] = new PointF(right, centerY);
    points[11] = new PointF(right, centerY);
    points[12] = new PointF(right, bottom - radius);
    points[13] = new PointF(right, bottom - radiusNub);
    points[14] = new PointF(right - radiusNub, bottom);
    points[15] = new PointF(right - radius, bottom);
    points[16] = new PointF(centerX, bottom);
    points[17] = new PointF(centerX, bottom);
    points[18] = new PointF(left + radius, bottom);
    points[19] = new PointF(left + radiusNub, bottom);
    points[20] = new PointF(left, bottom - radiusNub);
    points[21] = new PointF(left, bottom - radius);
    points[22] = new PointF(left, centerY);
    points[23] = new PointF(left, centerY);
    points[24] = new PointF(left, top + radius);
    // repeat existing points to prevent a gap
    points[25] = new PointF(left, top + radiusNub);
    points[26] = new PointF(left + radiusNub, top);
    points[27] = new PointF(left + radius, top);
    points[28] = new PointF(centerX, top);
    points[29] = new PointF(centerX, top);
    points[30] = new PointF(right - radius, top);

    dst.CopySurface(src, rect.Location, rect);

    using (RenderArgs ra = new RenderArgs(dst))
    {
        Graphics roundedRect = ra.Graphics;
        roundedRect.SmoothingMode = SmoothingMode.AntiAlias;
        roundedRect.Clip = new Region(rect);

        using (Pen roundedRectPen = new Pen(Color.FromArgb(Amount6, Amount5), Amount4))
        {
            roundedRect.DrawBeziers(roundedRectPen, points);
        }
    }
}

Edit: You may just want a dll.

RoundedRect.zip

Edited by toe_head2001
  • Upvote 2

(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

It may be worth making your own set of rounded rectangle custom shapes in a range of radii.
New custom shapes can be made using ShapeMaker here:http://forums.getpaint.net/index.php?/topic/32096-shapemaker-by-the-dwarf-horde-jan-30th-2016/

 

Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings

 

PdnForumSig2.jpg

Link to comment
Share on other sites

This has been on The List for awhile, never sure when it'll properly surface though :)

 

And in the meantime using a custom shape is a workaround, as long as you are confident in the exact radius that you want or willing to do some trial-and-error.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

@Red ochre's Squirkle plugin will create rather nice rounded rectangles.  Play with the Exponent setting to round or square the corners.

Link to comment
Share on other sites

  • 2 months later...

It is the same code posted by @toe_head2001, but you can change the radius for each corner separately.
Thank you toe_head2001.

 

Spoiler

// Name: Rounded Rectangle
// Submenu: Render
// Author: toe_head2001
// Title:
// Version: 0.9.1
// Desc:
// Keywords:
// URL:
// Help:
#region UICode
IntSliderControl Amount1 = 20; // [1,100] Line Width
IntSliderControl Amount2 = 255; // [0,255] Line Opacity
ColorWheelControl Amount3 = ColorBgra.FromBgr(0,0,0); // Line Color
IntSliderControl Amount4 = 400; // [2,1000] Rectangle Width
IntSliderControl Amount5 = 300; // [2,1000] Rectangle Height
IntSliderControl Amount6 = 50; // [0,500] Radius 1
IntSliderControl Amount7 = 50; // [0,500] Radius 2
IntSliderControl Amount8 = 50; // [0,500] Radius 3
IntSliderControl Amount9 = 50; // [0,500] Radius 4
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
    float centerX = ((selection.Right - selection.Left) / 2f) + selection.Left;
    float centerY = ((selection.Bottom - selection.Top) / 2f) + selection.Top;
    float left = centerX - Amount4 / 2f;
    float right = centerX + Amount4 / 2f;
    float top = centerY - Amount5 / 2f;
    float bottom = centerY + Amount5 / 2f;
    float radiusMax = Math.Min(Amount4, Amount5) / 2f;
    float radius1 = (Amount6 > radiusMax) ? radiusMax : Amount6;
    float radius2 = (Amount7 > radiusMax) ? radiusMax : Amount7;
    float radius3 = (Amount8 > radiusMax) ? radiusMax : Amount8;
    float radius4 = (Amount9 > radiusMax) ? radiusMax : Amount9;
    float radiusNub1 = radius1 / 2f;
    float radiusNub2 = radius2 / 2f;
    float radiusNub3 = radius3 / 2f;
    float radiusNub4 = radius4 / 2f;
    
    PointF[] points = new PointF[31];
    points[0] = new PointF(left, top + radius1);
    points[1] = new PointF(left, top + radiusNub1);
    points[2] = new PointF(left + radiusNub1, top);
    points[3] = new PointF(left + radius1, top);
    points[4] = new PointF(centerX, top);
    points[5] = new PointF(centerX, top);
    points[6] = new PointF(right - radius2, top);
    points[7] = new PointF(right - radiusNub2, top);
    points[8] = new PointF(right, top + radiusNub2);
    points[9] = new PointF(right, top + radius2);
    points[10] = new PointF(right, centerY);
    points[11] = new PointF(right, centerY);
    points[12] = new PointF(right, bottom - radius3);
    points[13] = new PointF(right, bottom - radiusNub3);
    points[14] = new PointF(right - radiusNub3, bottom);
    points[15] = new PointF(right - radius3, bottom);
    points[16] = new PointF(centerX, bottom);
    points[17] = new PointF(centerX, bottom);
    points[18] = new PointF(left + radius4, bottom);
    points[19] = new PointF(left + radiusNub4, bottom);
    points[20] = new PointF(left, bottom - radiusNub4);
    points[21] = new PointF(left, bottom - radius4);
    points[22] = new PointF(left, centerY);
    points[23] = new PointF(left, centerY);
    points[24] = new PointF(left, top + radius1);
    // repeat existing points to prevent a gap
    points[25] = new PointF(left, top + radiusNub1);
    points[26] = new PointF(left + radiusNub1, top);
    points[27] = new PointF(left + radius1, top);
    points[28] = new PointF(centerX, top);
    points[29] = new PointF(centerX, top);
    points[30] = new PointF(right - radius2, top);

    dst.CopySurface(src, rect.Location, rect);

    using (RenderArgs ra = new RenderArgs(dst))
    {
        Graphics roundedRect = ra.Graphics;
        roundedRect.SmoothingMode = SmoothingMode.AntiAlias;
        roundedRect.Clip = new Region(rect);

        using (Pen roundedRectPen = new Pen(Color.FromArgb(Amount2, Amount3), Amount1))
        {
            roundedRect.DrawBeziers(roundedRectPen, points);
        }
    }
}

 

 

  • Like 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...