Jump to content
How to Install Plugins ×
Paint.NET 5.1 is now available! ×

Recommended Posts

Posted

Spoked Wheel

Effects -> Render -> Spoked Wheel

 

ui.pngex1.png

 

Change Log

v1.1 (March 5, 2016)

  • Changed: The range for Line Thicknesses now maxes out at 100

v1.0 (Feb 20, 2016)

  • Initial release

 

Download

SpokedWheel.zip

 

Spoiler

SpokedWheel.png <---- Icon

 

// Name: Spoked Wheel
// Submenu: Render
// Author: toe_head2001
// Title:
// Version: 1.1
// Desc: Generates a Spoked Wheel
// Keywords:
// URL:
// Help:
#region UICode
IntSliderControl Amount1 = 5; // [3,20] Spokes
DoubleSliderControl Amount2 = 1; // [0.1,1] Wheel Size
DoubleSliderControl Amount3 = 0.333; // [0.1,0.9] Axle Size
IntSliderControl Amount4 = 2; // [1,100] Rim Thickness
ListBoxControl Amount5 = 0; // Rim Style|Solid|Dashed|Dotted
IntSliderControl Amount6 = 2; // [1,100] Spoke Thickness
ListBoxControl Amount7 = 0; // Spoke Style|Solid|Dashed|Dotted
IntSliderControl Amount8 = 2; // [1,100] Axle Thickness
ListBoxControl Amount9 = 0; // Axle Style|Solid|Dashed|Dotted
AngleControl Amount10 = 0; // [-180,180] Rotation
ColorWheelControl Amount11 = ColorBgra.FromBgr(0,0,0); // Color
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = EnvironmentParameters.SelectionBounds;
    float centerX = ((selection.Right - selection.Left) / 2f) + selection.Left;
    float centerY = ((selection.Bottom - selection.Top) / 2f) + selection.Top;
    float diameter = (float)Amount2 * Math.Min(selection.Width - 4, selection.Height - 4) - Amount4;
    float radius = diameter / 2f;
    float offsetX = centerX - radius;
    float offsetY = centerY - radius;
    float axleDiameter = (float)Amount3 * diameter;
    float axleOffsetX = centerX - axleDiameter / 2f;
    float axleOffsetY = centerY - axleDiameter / 2f;
    float start = (float)Amount10;
    float sweep = 360f / Amount1;

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

    using (Graphics wheel = new RenderArgs(dst).Graphics)
    {
        wheel.SmoothingMode = SmoothingMode.AntiAlias;
        wheel.Clip = new Region(rect);
        
        using (Pen wheelPen = new Pen(Amount11))
        {
            // Draw Rim
            wheelPen.Width = Amount4;
            wheelPen.DashStyle = getDashStyle(Amount5);
            wheel.DrawEllipse(wheelPen, offsetX, offsetY, diameter, diameter);
            
            // Draw Spokes
            wheelPen.Width = Amount6;
            wheelPen.DashStyle = getDashStyle(Amount7);
            for (int spoke = 0; spoke < Amount1; spoke++)
            {
                float degrees = start + sweep * spoke;
                double radians = Math.PI / 180 * degrees;

                float startX = (float)(radius * Amount3 * Math.Sin(radians));
                float startY = (float)(radius * Amount3 * Math.Cos(radians));
                
                float endX = (float)(radius * Math.Sin(radians));
                float endY = (float)(radius * Math.Cos(radians));

                wheel.DrawLine(wheelPen, centerX - startX, centerY - startY, centerX - endX, centerY - endY);
            }
            
            // Draw Axle
            wheelPen.Width = Amount8;
            wheelPen.DashStyle = getDashStyle(Amount9);
            wheel.DrawEllipse(wheelPen, axleOffsetX, axleOffsetY, axleDiameter, axleDiameter);
        }
    }
}

static DashStyle getDashStyle(byte style)
{
    DashStyle dashStyle;
    switch (style)
    {
        case 0: // Solid
            dashStyle = DashStyle.Solid;
            break;
        case 1: // Dashed
            dashStyle = DashStyle.Dash;
            break;
        case 2: // Dotted
            dashStyle = DashStyle.Dot;
            break;
        default:
            dashStyle = DashStyle.Solid;
            break;
    }
    return dashStyle;
}

 

 

  • Upvote 7
Posted

Thank you, toe_head! I'm sure I'll find a use for this... ;)        :beer:  :pizza:

 

 

 

Just what I needed, Thank you!

 

Space, the final frontier...

 

 

Eli, Beam me up!!   :)       (I'm a huge Trekkie...)

  • 2 weeks later...
  • 2 weeks later...
Posted (edited)

Here's the plugin compiled for the old PdN: Spoked Wheel 1.1 for PdN 3.5.11.zip

 

This may be a far-fetched application, but I think this is good for creating chopped trees, or maybe circular woody mazes. Of course the spoked wheel was just the starting point after which I had to do a couple additional things, but anyway, the spoked wheel took part and that's what counts :) Here are two quickies whose main objects I believe resemble chopped trees (maybe the first one looks more like a circular maze http://smiles.kolobok.us/artists/just_cuz/JC_thinking.gif). Perhaps the textures can be improved.

 

Scene 1:

 

Spoked_Wheel_Chopped_Tree_Trunk_-_scene_

Scene 2:

 

Spoked_Wheel_Chopped_Tree_Trunk_-_scene_

Edited by Maximilian
broken pic links repaired
  • Upvote 2
  • 2 years later...
  • 10 months later...
Posted (edited)
28 minutes ago, toe_head2001 said:

 

Sorry, there's no easy way to do that.

Agreed, there is actually a theoretical way I know how to do it. But, it requires warping image assuming distance from center is y and square borders as x, then create linear stroke, and transform it back where x axis is x and y axis is y. But, that is not easy at all.

 

Actually maybe polar transformation would be easier to code in. A lot easier in fact.

Edited by Reptillian

G'MIC Filter Developer

 

I am away from this forum for undetermined amount of time: If you really need anything related to my PDN plugin or my G'MIC filter within G'MIC plugin, then you can contact me via Paint.NET discord, and mention me.

Posted (edited)

The thing is that it's not consistent within the spokes. That's why I suggest polar transform. Generate the outlines within pre-transform vector, then polar transform right back. But, I'm not so qualified to know c# limitation in context of paint.net, but this is indeed possible within g'mic-qt and c++ within other programs.

Edited by Reptillian

G'MIC Filter Developer

 

I am away from this forum for undetermined amount of time: If you really need anything related to my PDN plugin or my G'MIC filter within G'MIC plugin, then you can contact me via Paint.NET discord, and mention me.

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