/// <summary> /// Returns a DistortedOutlineShape based on the current shape and a SpiralDistortion. /// A regular polygon with more than six corners is returned unmodified. /// </summary> /// <param name="r"></param> /// <returns></returns> private SmoothOutlineShape SpiralDistortedCopy(Random r) { if (this.windings == 1 && this.corners > 6) { return(this); } // d: radial distance between an edge midpoint and a corner double d = this.sz - this.xEdge; // dr: the same, relative to the shape size double dr = d / this.sz; // this would wind one corner to the following corner (over the full shape size) double maxSpiralWinding = (double)this.windings / (double)this.corners; // this would wind a midpoint to a corner (over their radial distance) // this is sufficient to make the corner hang over and form a hook maxSpiralWinding /= (2.0 * dr); // this will produce even stronger overhanging corners maxSpiralWinding *= (this.windings == 1 ? 1.5 : 1.2); // Choose an actual winding ratio. double w = (0.33 + 0.66 * r.NextDouble()) * maxSpiralWinding; w = maxSpiralWinding; if (r.Next(2) == 0) { w *= -1; } DistortedOutlineShape.Distortion distortion = DistortedOutlineShape.SpiralDistortion(this.xc, this.yc, this.sz, w); return(this.DistortedCopy(distortion)); }