toe_head2001 1,281 Report post Posted February 21, 2016 (edited) Spoked Wheel Effects -> Render -> Spoked Wheel 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 <---- Icon GPL v3 // 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.GetSelection(src.Bounds).GetBoundsInt(); 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; } Edited March 27, 2017 by toe_head2001 7 Share this post Link to post Share on other sites
BoltBait 2,170 Report post Posted February 21, 2016 You could shorten up the UI by changing those radio buttons into drop-down lists. Share this post Link to post Share on other sites
toe_head2001 1,281 Report post Posted February 21, 2016 You could shorten up the UI by changing those radio buttons into drop-down lists. Dang it, I meant to change those before posting. Anyway, they're drop-down lists now. Share this post Link to post Share on other sites
Eli 1,005 Report post Posted February 21, 2016 (edited) Just what I needed, Thank you! Edited February 21, 2016 by Eli 2 Share this post Link to post Share on other sites
lynxster4 2,049 Report post Posted February 21, 2016 Thank you, toe_head! I'm sure I'll find a use for this... Just what I needed, Thank you! Space, the final frontier... Eli, Beam me up!! (I'm a huge Trekkie...) Share this post Link to post Share on other sites
skullbonz 358 Report post Posted February 22, 2016 Couldn't this be done with Red Ochre's Gears plugin ? 1 Share this post Link to post Share on other sites
Eli 1,005 Report post Posted February 22, 2016 Hello skullbonz, Thanks for the tip, I tried Gears and this is what I came up " Not all spoked wheels are made the same" Share this post Link to post Share on other sites
toe_head2001 1,281 Report post Posted February 22, 2016 Couldn't this be done with Red Ochre's Gears plugin ? This plugin was specifically requested by @Eli. Share this post Link to post Share on other sites
Eli 1,005 Report post Posted February 22, 2016 Yes, the Spoked Wheel effect is designed to slice a circle into equal parts. In the example above, both have 5 spokes. Share this post Link to post Share on other sites
toe_head2001 1,281 Report post Posted March 5, 2016 Version 1.1 posted. The Line Thicknesses can now go up to 100. Sorry Eli, I had this new version ready two weeks ago when you asked me about the line thickness. I simply forgot to post it. 3 Share this post Link to post Share on other sites
Eli 1,005 Report post Posted March 5, 2016 Thanks toe_head2001, the adjustments work very well. The thicker lines are large enough when working on a very large canvas. Share this post Link to post Share on other sites
Maximilian 1,661 Report post Posted March 14, 2016 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 ). Perhaps the textures can be improved. Scene 1: Scene 2: 2 Share this post Link to post Share on other sites