Ejemplo n.º 1
0
            protected override void Update()
            {
                base.Update();

                // the point at which alpha is saturated and we begin to adjust colour lightness.
                const float lighten_cutoff = 0.95f;

                // the amount of lightness to attribute regardless of relative value to peak point.
                const float non_relative_portion = 0.2f;

                float amount = 0;

                // give some amount of alpha regardless of relative count
                amount += non_relative_portion * Math.Min(1, count / 10f);

                // add relative portion
                amount += (1 - non_relative_portion) * (count / heatmap.PeakValue);

                // apply easing
                amount = (float)Interpolation.ApplyEasing(Easing.OutQuint, Math.Min(1, amount));

                Debug.Assert(amount <= 1);

                Alpha = Math.Min(amount / lighten_cutoff, 1);
                if (pointType == HitPointType.Hit)
                {
                    Colour = BaseColour.Lighten(Math.Max(0, amount - lighten_cutoff));
                }
            }
Ejemplo n.º 2
0
        protected override void Update()
        {
            base.Update();
            spinningMiddle.Rotation = discTop.Rotation = drawableSpinner.RotationTracker.Rotation;
            discBottom.Rotation     = discTop.Rotation / 3;

            Scale = new Vector2(final_scale * (0.8f + (float)Interpolation.ApplyEasing(Easing.Out, drawableSpinner.Progress) * 0.2f));
        }
Ejemplo n.º 3
0
        protected override void Update()
        {
            base.Update();
            spinningMiddle.Rotation = discTop.Rotation = DrawableSpinner.RotationTracker.Rotation;
            discBottom.Rotation     = discTop.Rotation / 3;

            glow.Alpha = DrawableSpinner.Progress;

            scaleContainer.Scale = new Vector2(SPRITE_SCALE * (0.8f + (float)Interpolation.ApplyEasing(Easing.Out, DrawableSpinner.Progress) * 0.2f));
        }
Ejemplo n.º 4
0
        private double inverseEasing(Easing easing, double targetValue)
        {
            double test   = 0;
            double result = 0;
            int    count  = 2;

            while (Math.Abs(result - targetValue) > 0.005)
            {
                int dir = Math.Sign(targetValue - result);

                test  += dir * 1.0 / count;
                result = Interpolation.ApplyEasing(easing, test);

                count++;
            }

            return(test);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     更新
        ///     會更新物件位置
        /// </summary>
        protected void UpdateProgress(double currentTime)
        {
            //開始 結束 進度
            var startProgress = PathPrecentageCounter.CalculatePrecentage(_hitObject.StartTime - currentTime + DelayTime);
            var endProgress   = PathPrecentageCounter.CalculatePrecentage(_hitObject.EndTime - currentTime + DelayTime);
            //影響程度
            var CurveEasingTypesPrecentage = _hitObject.CurveEasingTypesPrecentage;

            //修正
            startProgress = MathHelper.Clamp(startProgress, 0, 1);
            endProgress   = MathHelper.Clamp(endProgress, 0, 1);
            //根據設定曲線去改變百分比
            startProgress = Interpolation.ApplyEasing(_hitObject.CurveEasingTypes, startProgress, 0, 1, 1) * CurveEasingTypesPrecentage + startProgress * (1 - CurveEasingTypesPrecentage);
            endProgress   = Interpolation.ApplyEasing(_hitObject.CurveEasingTypes, endProgress, 0, 1, 1) * CurveEasingTypesPrecentage + endProgress * (1 - CurveEasingTypesPrecentage);


            //更新開始打擊和放開打擊的位置定義
            Components.ForEach(c => c.UpdateProgress(startProgress, endProgress));
        }
Ejemplo n.º 6
0
        protected override void Update()
        {
            base.Update();

            if (Logo == null)
            {
                return;
            }

            if (Logo.RelativePositionAxes != Axes.Both)
            {
                throw new InvalidOperationException($"Tracking logo must have {nameof(RelativePositionAxes)} = Axes.Both");
            }

            // Account for the scale of the actual OsuLogo, as SizeForFlow only accounts for the sprite scale.
            facade.SetSize(new Vector2(Logo.SizeForFlow * Logo.Scale.X));

            var localPos = ComputeLogoTrackingPosition();

            if (LogoFacade.Parent != null && Logo.Position != localPos)
            {
                // If this is our first update since tracking has started, initialize our starting values for interpolation
                if (startTime == null || startPosition == null)
                {
                    startTime     = Time.Current;
                    startPosition = Logo.Position;
                }

                if (duration != 0)
                {
                    double elapsedDuration = (double)(Time.Current - startTime);

                    float amount = (float)Interpolation.ApplyEasing(easing, Math.Min(elapsedDuration / duration, 1));

                    // Interpolate the position of the logo, where amount 0 is where the logo was when it first began interpolating, and amount 1 is the target location.
                    Logo.Position = Vector2.Lerp(startPosition.Value, localPos, amount);
                }
                else
                {
                    Logo.Position = localPos;
                }
            }
        }
Ejemplo n.º 7
0
        protected override void Update()
        {
            base.Update();

            if (BeatSyncSource.ControlPoints == null || BeatSyncSource.Clock == null)
            {
                return;
            }

            metronomeClock.Rate = IsBeatSyncedWithTrack ? BeatSyncSource.Clock.Rate : 1;

            timingPoint = BeatSyncSource.ControlPoints.TimingPointAt(BeatSyncSource.Clock.CurrentTime);

            if (beatLength != timingPoint.BeatLength)
            {
                beatLength = timingPoint.BeatLength;

                EarlyActivationMilliseconds = timingPoint.BeatLength / 2;

                float bpmRatio = (float)Interpolation.ApplyEasing(Easing.OutQuad, Math.Clamp((timingPoint.BPM - 30) / 480, 0, 1));

                weight.MoveToY((float)Interpolation.Lerp(0.1f, 0.83f, bpmRatio), 600, Easing.OutQuint);
                this.TransformBindableTo(interpolatedBpm, (int)Math.Round(timingPoint.BPM), 600, Easing.OutQuint);
            }

            if (BeatSyncSource.Clock?.IsRunning != true && isSwinging)
            {
                swing.ClearTransforms(true);

                using (swing.BeginDelayedSequence(350))
                {
                    swing.RotateTo(0, 1000, Easing.OutQuint);
                    stick.FadeColour(overlayColourProvider.Colour2, 1000, Easing.OutQuint);
                }

                isSwinging = false;

                clunkDelegate?.Cancel();
                clunkDelegate = null;
            }
        }
Ejemplo n.º 8
0
        //update progress
        public static void UpdateTemplate(this IHasTemplate drawableObject, double currentTime)
        {
            //start progress
            var startProgress = PathPrecentageCounter.CalculatePrecentage(drawableObject.RpObject.StartTime - currentTime + DelayTime, 1);
            //end progress
            var endProgress = PathPrecentageCounter.CalculatePrecentage(drawableObject.RpObject.StartTime - currentTime + DelayTime, 1);

            //影響程度
            var CurveEasingTypesPrecentage = 0;

            //修正
            startProgress = MathHelper.Clamp(startProgress, 0, 1);
            endProgress   = MathHelper.Clamp(endProgress, 0, 1);
            //fix precentage by EasingTypes
            startProgress = Interpolation.ApplyEasing(Easing.None, startProgress, 0, 1, 1) * CurveEasingTypesPrecentage + startProgress * (1 - CurveEasingTypesPrecentage);
            endProgress   = Interpolation.ApplyEasing(Easing.None, endProgress, 0, 1, 1) * CurveEasingTypesPrecentage + endProgress * (1 - CurveEasingTypesPrecentage);

            //update all
            foreach (IComponentUpdateEachFrame single in drawableObject.Components.Where(n => n is IComponentUpdateEachFrame))
            {
                single.UpdateProgress(startProgress, endProgress);
            }
        }
Ejemplo n.º 9
0
 public void TestEasingEndsAtOne(Easing easing) => Assert.That(Interpolation.ApplyEasing(easing, 1), Is.EqualTo(1).Within(Precision.DOUBLE_EPSILON));
Ejemplo n.º 10
0
 public void TestEasingStartsAtZero(Easing easing) => Assert.That(Interpolation.ApplyEasing(easing, 0), Is.EqualTo(0).Within(Precision.DOUBLE_EPSILON));