static public float ElasticInOut(AnimationEasing easing, float time) { if (time <= 0.5f) { return easing.In(time * 2f) / 2f; } else { return (easing.Out((time - 0.5f) * 2f) / 2f) + 0.5f; } }
public void HandleContainerScale(double valStart, double valEnd) { if (containerPlayerDisplay == null) { return; } if (containerPlayerDisplay.transform.childCount == 0) { return; } if (containerRotator == null) { return; } string keyScale = "scale-" + uuid; //Debug.Log("HandleContainerScale:" + " valStart:" + valStart + " valEnd:" + valEnd); AnimationEasing.EaseAdd( keyScale, AnimationEasing.Equations.QuadEaseInOut, currentContainerScale, valStart, valEnd, .5, .1 ); }
public AnimationMotion(int endX, int endY, int msDuration, AnimationEasing easing) { EndX = endX; EndY = endY; MsDuration = msDuration; Easing = easing; }
public void HandleContainerRotation(double valStart, double valEnd) { if (containerPlayerDisplay == null) { return; } if (containerPlayerDisplay.transform.childCount == 0) { return; } if (containerRotator == null) { return; } containerRotator.ResetRigidBodiesVelocity(); string keyRotation = "rotation-" + uuid; //Debug.Log("HandleContainerRotation:" + " valStart:" + valStart + " valEnd:" + valEnd); AnimationEasing.EaseAdd(keyRotation, AnimationEasing.Equations.QuadEaseInOut, currentContainerRotation, valStart, valEnd, .5, .1); }
// Create Animator private void Setup(float dur, float delay, AnimationEasingType eas, EasingType typ, AnimationDriveType d) { startTime = Time.time + delay; duration = dur; easingType = typ; easing = new AnimationEasing(eas); drive = new AnimationDrive(d); }
/// <summary> /// Animate toggle /// </summary> private void OnIsToggledChanged(bool toggled) { AnimationExtensions.AbortAnimation(this, _animationName); double start = _toggledAnimationProcessWithoutEasing; double end = 1; if (toggled == false) { start = _toggledAnimationProcessWithoutEasing; end = 0; } Animation anim = new Animation(d => { if (toggled) { _toggledAnimationProcess = AnimationEasing.Ease(d); } else { _toggledAnimationProcess = 1 - AnimationEasing.Ease(1 - d); } _toggledAnimationProcessWithoutEasing = d; _skiaCanvas.InvalidateSurface(); }, start, end); anim.Commit(this, _animationName, 64, (uint)AnimationDuration, Easing.Linear); }
/// <summary> /// Initializes a new instance of the Animation class. /// </summary> /// <param name="target">Target object for animation</param> /// <param name="targetPropertyName">Target property name for animation</param> public Animation(AnimationRequest[] animationRequests, AnimationEasing animationEasing, int animationDuration) { if (animationRequests != null && animationRequests.Length > 0) _AnimationList.AddRange(animationRequests); _EasingFunction = animationEasing; _Duration = (int)animationDuration; InitializeAnimationFunctions(); }
static public float InOut(AnimationEasing eas, float time) { if (time <= 0.5f) { return(eas.In(time * 2) / 2); } else { return((eas.Out((time - 0.5f) * 2) / 2) + 0.5f); } }
public void UpdateScale() { if (containerPlayerDisplay == null) { return; } if (containerPlayerDisplay.transform.childCount == 0) { return; } if (containerRotator == null) { return; } string keyScale = "scale-" + uuid; if (AnimationEasing.EaseExists(keyScale)) { AnimationEasing.AnimationItem aniItem = AnimationEasing.EaseGet(keyScale); currentContainerScale = aniItem.val;//AnimationEasing.EaseGetValue(keyScale, 1.0f); if (currentContainerScale != scaleMax || currentContainerScale != scaleMin) { currentContainerScale = (double)Mathf.Clamp((float)currentContainerScale, (float)scaleMin, (float)scaleMax); //Debug.Log("UpdateScale:" + " currentContainerScale:" + currentContainerScale); float scaleTo = (float)currentContainerScale; float zoomAdjustY = 0f; containerRotator.transform.localScale = Vector3.zero .WithX(scaleTo) .WithY(scaleTo) .WithZ(scaleTo); zoomAdjustY = -(Mathf.Abs((float)aniItem.valEnd - scaleTo) / 5); if (zoomAdjust && aniItem.valEnd > aniItem.valStart) { zoomAdjustY = -(scaleTo / (float)zoomAdjustAmount); } containerRotator.transform.localPosition = Vector3.zero.WithY(zoomAdjustY); ; } } }
/// <summary> /// Animate toggle /// </summary> private void OnIsToggledChanged(bool toggled, bool isEllipseAnimationEnabled = true) { if (_ignoreIsToggledEventHandling) { return; } _ignoreIsToggledEventHandling = true; IsToggled = toggled; _ignoreIsToggledEventHandling = false; AnimationExtensions.AbortAnimation(this, _animationName); if (IsToggled) { HandleGroupIsToggledChanged(IsToggled); } double start = _toggledAnimationProcessWithoutEasing; double end = 1; if (toggled == false) { start = _toggledAnimationProcessWithoutEasing; end = 0; } Animation anim = new Animation(d => { _toggledAnimationProcess = AnimationEasing.Ease(d); _toggledAnimationProcessWithoutEasing = d; if (isEllipseAnimationEnabled) { _ellipseAnimationProcess = d; } _skiaCanvas.InvalidateSurface(); }, start, end); anim.Commit(this, _animationName, 64, (uint)AnimationDuration, Easing.Linear); }
/// <summary> /// Initializes a new instance of the Animation class. /// </summary> /// <param name="target">Target object for animation</param> /// <param name="targetPropertyName">Target property name for animation</param> public AnimationInt(AnimationRequest[] animationRequests, AnimationEasing animationEasing, int animationDuration) : base(animationRequests, animationEasing, animationDuration) { }
/// <summary> /// Initializes a new instance of the Animation class. /// </summary> /// <param name="target">Target object for animation</param> /// <param name="targetPropertyName">Target property name for animation</param> public AnimationInt(AnimationRequest animationRequest, AnimationEasing animationEasing, int animationDuration) : base(new AnimationRequest[] { animationRequest }, animationEasing, animationDuration) { }
public AnimationConfigBuilder Easing(AnimationEasing value) { base.Options["easing"] = value; return(this); }
public Animation(AnimationEasing Easing, int Duration) { this.Easing = Easing; this.Duration = (int?)Duration; }
public static float InOut(AnimationEasing eas, float time) { if (time <= 0.5f) return eas.In(time * 2) / 2; else return (eas.Out((time - 0.5f) * 2) / 2) + 0.5f; }
public void UpdateRotator() { if (containerPlayerDisplay == null) { return; } if (containerPlayerDisplay.transform.childCount == 0) { return; } if (containerRotator == null) { return; } if (rotatorRigidbody == null) { rotatorRigidbody = containerRotator.GetOrSet <Rigidbody>(); } if (rotateObject == null) { rotateObject = containerRotator.GetOrSet <RotateObject>(); } if (rotatorCollider == null) { rotatorCollider = containerRotator.GetOrSet <CapsuleCollider>(); } //rotateObject.enabled = false; if (allowRotator) { if (rotatorRigidbody != null) { rotatorRigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; } if (rotateObject != null) { rotateObject.RotateSpeedAlongY = 2; } string keyRotation = "rotation-" + uuid; if (AnimationEasing.EaseExists(keyRotation)) { currentContainerRotation = AnimationEasing.EaseGetValue(keyRotation, 0.0f); currentContainerRotation = (double)Mathf.Clamp((float)currentContainerRotation, (float)rotationMin, (float)rotationMax); //Debug.Log("UpdateScale:" + " currentContainerScale:" + currentContainerScale); float rotateTo = (float)currentContainerRotation; containerRotator.transform.localRotation = Quaternion.Euler(Vector3.zero .WithX(0) .WithY(rotateTo * 360) .WithZ(0)); } } else { containerRotator.ResetObject(); if (rotatorRigidbody != null) { rotatorRigidbody.constraints = RigidbodyConstraints.FreezeAll; } if (rotateObject != null) { rotateObject.RotateSpeedAlongY = 0; } } }
/// <summary> /// Initializes a new instance of the Animation class. /// </summary> /// <param name="target">Target object for animation</param> /// <param name="targetPropertyName">Target property name for animation</param> public AnimationPoint(AnimationEasing animationEasing, int animationDuration) : base(new AnimationRequest[0], animationEasing, animationDuration) { }
public AnimationMotion(Point end, int msDuration, AnimationEasing easing) : this(end.X, end.Y, msDuration, easing) { }
/// <summary> /// Initializes a new instance of the Animation class. /// </summary> /// <param name="target">Target object for animation</param> /// <param name="targetPropertyName">Target property name for animation</param> public Animation(AnimationRequest animationRequest, AnimationEasing animationEasing, int animationDuration) : this(new AnimationRequest[] { animationRequest }, animationEasing, animationDuration) { }