public bool Hide(Edge edge = Edge.None, float duration = -1, IEaseFunction easeFunction = null) { switch (State) { case TweenState.Leaving: case TweenState.Hidden: return(false); } if (edge == Edge.None) { edge = GetClosestEdge(); } if (duration == -1) { duration = Duration; } if (easeFunction == null) { easeFunction = ExitTween; } if (targetPosition.X == -1) { targetPosition.X = Position.X; } if (targetPosition.Y == -1) { targetPosition.Y = Position.Y; } State = TweenState.Leaving; Enabled = true; Visible = true; Vector2 to = position; Vector2 view = ViewportSize; switch (edge) { case Edge.Left: to.X = -Width; break; case Edge.Right: to.X = view.X; break; case Edge.Top: to.Y = -Height; break; case Edge.Bottom: to.Y = view.Y; break; } interpolator = new Tweener(position, to, duration, easeFunction); return(true); }
public Tweener( Vector2 from, Vector2 to, float duration, IEaseFunction easeFunction ) { this.from = from; this.to = to; this.duration = duration; this.easeFunction = easeFunction; invDuration = 1f / duration; distance = to - from; Restart(); }
public Tweener(Vector2 from, Vector2 to, float duration, IEaseFunction easeFunction) { this.from = from; this.to = to; this.duration = duration; this.easeFunction = easeFunction; invDuration = 1f / duration; distance = to - from; Restart(); }
public bool Toggle(Edge edge = Edge.None, float duration = -1, IEaseFunction easeFunction = null) { if (IsFullyShown) { return(Hide(edge, duration, easeFunction)); } else if (IsFullyHidden) { return(Show(edge, duration, easeFunction)); } return(false); }
public void Init(TweenTime timeProvider, TweenBuilder builder) { this.timeProvider = timeProvider; this.tweener = builder.Tweener; this.easeType = builder.EaseType; this.tweenType = builder.TweenType; this.easeFunction = builder.EaseFunction; this.duration = builder.Duration; this.delayTime = builder.Delay; this.handler = builder.Handler; this.startTime = 0; this.realTime = 0; this.pauseTime = 0; }
public bool Show(Edge edge = Edge.None, float duration = -1, IEaseFunction easeFunction = null) { switch (State) { case TweenState.Entering: case TweenState.Shown: return(false); } if (edge == Edge.None) { edge = GetClosestEdge(); } if (duration == -1) { duration = Duration; } if (easeFunction == null) { easeFunction = EntryTween; } Vector2 view = ViewportSize; if (targetPosition.X == -1) { switch (edge) { case Edge.Left: targetPosition.X = 0; break; case Edge.Right: targetPosition.X = view.X - Width; break; } } if (targetPosition.Y == -1) { switch (edge) { case Edge.Top: targetPosition.Y = 0; break; case Edge.Bottom: targetPosition.Y = view.Y - Height; break; } } State = TweenState.Entering; Enabled = true; Visible = true; Vector2 from = targetPosition; switch (edge) { case Edge.Left: from.X = -Width; break; case Edge.Right: from.X = view.X; break; case Edge.Top: from.Y = -Height; break; case Edge.Bottom: from.Y = view.Y; break; } interpolator = new Tweener(from, targetPosition, duration, easeFunction); return(true); }
public TweenBuilder WithEaseFunction(IEaseFunction easeFunction) { this.easeFunction = easeFunction; return(this); }