public void Cycle(bool clockwise)
        {
            for (int i = 0; i < count; i++)
            {
                var original = i;
                original = RangeMath.CycleInt(original, count - 1, !clockwise);
                BeginSlide(original, i);
            }

            cooldown = true;
        }
    IEnumerator RotateWorld(bool clockwise)
    {
        rotating         = true;
        movement.gravity = Vector3.zero;

        GravityState oldState = gravityStates[gravityIndex];

        gravityIndex = RangeMath.CycleInt(gravityIndex, gravityStates.Length - 1, clockwise);
        GravityState newState = gravityStates[gravityIndex];

        Quaternion oldRotation = Quaternion.Euler(oldState.objectRotation);
        Quaternion newRotation = Quaternion.Euler(newState.objectRotation);

        float oldZAngle = pivot.localEulerAngles.z;
        float newZAngle = oldZAngle + rotationDegrees * (clockwise ? -1 : 1);

        float timer = 0;

        while (timer < rotationTime)
        {
            timer += Time.deltaTime;
            if (timer > rotationTime)
            {
                timer = rotationTime;
            }

            foreach (Transform rotor in toRotate)
            {
                rotor.rotation = Quaternion.Lerp(oldRotation, newRotation, timer / rotationTime);
            }

            float z = Mathf.Lerp(oldZAngle, newZAngle, timer / rotationTime);
            VectorMath.SetZRotation(pivot, z);

            yield return(null);
        }

        movement.gravity = newState.gravityDirection;
        rotating         = false;
    }
 public void Cycle(bool clockwise)
 {
     index = RangeMath.CycleInt(index, gravityDirections.Length - 1, clockwise);
 }
Exemple #4
0
        public static void ComputeHistogram(Bitmap input, string param)
        {
            param = param.Trim();

            bool ColorPalete = (param[0] == ColorPaleteCommnad); //ColorPalete
            bool Histogram   = (param[0] == HistogramCommnad);   //Histogram
            bool Values      = (param[0] == ValuesCommnad);      //Values
            bool Powers      = (param[0] == PowersCommnad);      //Powers

            bool total = ColorPalete || Histogram || Values || Powers;

            bool onlyOne = BoolMath.OnlyOne(ColorPalete, Histogram, Values, Powers);

            if (!total)
            {
                MessageBox.Show("Missing starting command");
                mode = ImageHistogramHsvMode.None;
                return;
            }
            if (!onlyOne)
            {
                MessageBox.Show("To many commands");
                mode = ImageHistogramHsvMode.None;
                return;
            }

            if (ColorPalete)
            {
                mode  = ImageHistogramHsvMode.Standart;
                param = param.Substring(param.IndexOf(ColorPaleteCommnad) + 1);
                Dictionary <string, string> rec = Util.ParseKeyValueList(param, ' ');


                int hue        = ImageHistogramHsvExist.OptimalHue;
                int saturation = ImageHistogramHsvExist.OptimalSaturation;

                Util.TryParse(rec, "Hue", ref hue);
                RangeMath.InRangeOrDefault(ref hue, ImageHistogramHsvExist.MinHue, ImageHistogramHsvExist.MaxHue, ImageHistogramHsvExist.OptimalHue);
                Util.TryParse(rec, "Sat", ref saturation);
                RangeMath.InRangeOrDefault(ref saturation, ImageHistogramHsvExist.MinSaturation, ImageHistogramHsvExist.MaxSaturation, ImageHistogramHsvExist.OptimalSaturation);

                if (rec.ContainsKey("Colors") && rec["Colors"] == "Dynamic")
                {
                    ImageHistogramHsvExist.DynamicColors = true;
                }
                else if (rec.ContainsKey("Colors") && rec["Colors"] == "Discrete")
                {
                    ImageHistogramHsvExist.DynamicColors = false;
                }
                else
                {
                    ImageHistogramHsvExist.DynamicColors = true;
                }
                ImageHistogramHsvExist.ComputeHistogram(input, hue, saturation + 1);
            }
            else if (Histogram || Powers || Values)
            {
                if (Histogram)
                {
                    mode  = ImageHistogramHsvMode.Distribution;
                    param = param.Substring(param.IndexOf(HistogramCommnad) + 1);
                }
                if (Values)
                {
                    mode  = ImageHistogramHsvMode.Vals;
                    param = param.Substring(param.IndexOf(ValuesCommnad) + 1);
                }
                if (Powers)
                {
                    mode  = ImageHistogramHsvMode.Power;
                    param = param.Substring(param.IndexOf(PowersCommnad) + 1);
                }

                Dictionary <string, string> rec = Util.ParseKeyValueList(param, ' ');

                int   hue  = ImageHistogramHsvOcc.OptimalHue;
                float zoom = ImageHistogramHsvOcc.OptimalZoom;
                Util.TryParse(rec, "Hue", ref hue);
                RangeMath.InRangeOrDefault(ref hue, ImageHistogramHsvOcc.MinHue, ImageHistogramHsvOcc.MaxHue, ImageHistogramHsvOcc.OptimalHue);
                if (!Util.TryParse(rec, "Zoom", ref zoom) && rec.ContainsKey("Zoom") && (rec["Zoom"] == "A" || rec["Zoom"] == "Auto"))
                {
                    ImageHistogramHsvOcc.AutoZoom = true;
                }
                else
                {
                    ImageHistogramHsvOcc.AutoZoom = false;
                }
                ImageHistogramHsvOcc.Zoom = zoom;
                ImageHistogramHsvOcc.ComputeHistogram(input, mode, hue + 1);
            }
        }