Esempio n. 1
0
        /// <summary>
        /// Returns a DistortedOutlineShape based on the current shape and a RadialWaveDistortion.
        /// The distortion is exactly aligned with the polygon shape.
        /// Only the polygon edges will be bent inwards; the points will not be distorted.
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        private SmoothOutlineShape RadialWaveDistortedCopy(Random r)
        {
            int n = this.corners;
            int w = this.windings;

            // Note: When slant = 0, our polygons are always oriented so that one edge is in the south.
            double a;

            if (n % 2 == 0)
            {
                // For multiples of 2, there is also an edge in the north.
                // Choose a to be the negative (relative) angle of the eastern corner on that edge.
                a = -(0.25 - 0.5 * w / n);
            }
            else
            {
                // Otherwise, one corner is in the north.
                a = -0.25;
            }
            a += this.slant / (2.0 * Math.PI);

            double bMin = 0.2 + (n + w - 2) * 0.03;         // strongly bent edges
            double bMax = 0.75 + (n - 2) * 0.01;            // slightly bent edges
            double b    = bMin + r.NextDouble() * (bMax - bMin);

            DistortedOutlineShape.Distortion distortion = DistortedOutlineShape.RadialWaveDistortion(this.xc, this.yc, n, a, b);
            return(this.DistortedCopy(distortion));
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a DistortedOutlineShape based on the current shape and a RadialWaveDistortion.
        /// A regular polygon with more than six corners is returned unmodified.
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        private SmoothOutlineShape RadialWaveDistortedCopy(Random r)
        {
            int    n    = 3 + r.Next(6);                // number of corners
            double a    = r.NextDouble();               // rotation, 0..1
            double bMin = 0.2 + (n - 2) * 0.03;         // strongly indented sides
            double bMax = 0.85 + (n - 2) * 0.0166;      // almost flat sides
            double b    = bMin + r.NextDouble() * (bMax - bMin);

            DistortedOutlineShape.Distortion distortion = DistortedOutlineShape.RadialWaveDistortion(this.xc, this.yc, n, a, b);
            return(this.DistortedCopy(distortion));
        }