Esempio n. 1
0
        /// <summary>
        /// Handles mouse-wheel change.
        /// </summary>
        /// <returns>True if handled.</returns>
        public override bool MouseWheel(MouseEventArgs e)
        {
            float dZoom = e.Delta / 120.0f;

            Zoom *= (float)Math.Pow(1.04, dZoom);

            // zoom bounds:
            Zoom = Arith.Clamp(Zoom, MinZoom, MaxZoom);
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Deterministic restart of a sequence.
        /// </summary>
        /// <param name="ij">Random seed #1 [0,31328]</param>
        /// <param name="kl">Random seed #2 [0,30081]</param>
        public void Reset(int ij, int kl)
        {
            double s, t;
            int    i, j, k, l, m;
            int    ii, jj;

            ij = Arith.Clamp(ij, 0, 31328);
            kl = Arith.Clamp(kl, 0, 30081);
            Ok = true;

            i = ((ij / 177) % 177) + 2;
            j = (ij % 177) + 2;
            k = ((kl / 169) % 178) + 1;
            l = (kl % 169);

            for (ii = 0; ii < 97; ii++)
            {
                s = 0.0;
                t = 0.5;
                for (jj = 0; jj++ < 24;)
                {
                    m = ((i * j % 179) * k) % 179;
                    i = j;
                    j = k;
                    k = m;
                    l = (53 * l + 1) % 169;
                    if (l * m % 64 >= 32)
                    {
                        s += t;
                    }
                    t *= 0.5;
                }

                u[ii] = s;
            }

            c  = 362436.0 / 16777216.0;
            cd = 7654321.0 / 16777216.0;
            cm = 16777213.0 / 16777216.0;

            i97 = 96;
            j97 = 32;
        }