protected virtual void Update() { tempoDecorrido += Time.deltaTime; switch (fase) { case FasesDaMovimentacao.esperandoMove: if (tempoDecorrido > tempoEsperando) { distanciaDeDeslocamento = Vector3.Distance(PreviousMoveTarget, MovePoints[MoveTarget].position); fase = FasesDaMovimentacao.move; MoveAnimation(); FlipDirection.Flip(transform, -PreviousMoveTarget.x + MovePoints[MoveTarget].position.x); tempoDecorrido = 0; } break; case FasesDaMovimentacao.move: if (MovePoints.Length > 0) { transform.position = Vector3.Lerp(PreviousMoveTarget, MovePoints[MoveTarget].position, tempoDecorrido * velocidadeDoDeslocamento / distanciaDeDeslocamento); } if (tempoDecorrido * velocidadeDoDeslocamento > distanciaDeDeslocamento) { EsperandoMoveAnimation(); fase = FasesDaMovimentacao.esperandoMove; tempoDecorrido = 0; TrocaMoveTarget(); } break; } }
void VerifiqueInvestida() { if (Time.time - ultimaInvestida > INTERVALO_DE_INVESTIMENTOS && Vector3.Distance(GameController.g.Manager.transform.position, transform.position) < DISTANCIA_DO_INVESTIMENTO) { RaycastHit2D hit = Physics2D.Linecast(transform.position, GameController.g.Manager.transform.position, 511); if (!hit) { ultimaInvestida = Time.time; _Animator.SetTrigger("preparaInvestida"); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.Wind1)); estado = EstadoDaqui.preparandoInvestida; dirGuardada = GameController.g.Manager.transform.position - transform.position; dirGuardada.Normalize(); qAlvo = Quaternion.LookRotation(Vector3.forward, Vector3.Cross(dirGuardada, Vector3.forward)); FlipDirection.Flip(transform, dirDeMovimento.x); new MyInvokeMethod().InvokeNoTempoDeJogo(gameObject, () => { EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, impulso)); dirGuardada = GameController.g.Manager.transform.position - transform.position; dirGuardada.Normalize(); dirGuardada *= VEL_DA_INVESTIDA; transform.rotation = Quaternion.LookRotation(Vector3.forward, Vector3.Cross(dirGuardada, Vector3.forward)); estado = EstadoDaqui.investindo; }, TEMPO_PREPARANDO); } } }
void PreparaAttack(bool magia, AnimKey a) { InvocaTeleportProps(true); _Animator.SetTrigger(a.ToString()); FlipDirection.Flip(transform, -(HeroPosition.x - transform.position.x)); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SorteieSom(magia))); }
/// <summary> /// Flip. /// </summary> /// <param name="transform">Transform.</param> /// <param name="direction">Flip direction.</param> /// <returns>Transform.</returns> public static ITransformation Flip(this ITransformation transform, FlipDirection direction) { switch (direction) { case FlipDirection.Both: transform.Translate(transform.Width, transform.Height); transform.Scale(-1.0, -1.0); break; case FlipDirection.Horizontal: transform.Translate(0, transform.Height); transform.Scale(1.0, -1.0); break; case FlipDirection.Vertical: transform.Translate(transform.Width, 0); transform.Scale(-1.0, 1.0); break; default: throw new Exception($"Unsupported flip direction: {direction}"); } return(transform); }
private void ImageFlip(FlipDirection direction) { ImageSizing imageSize = new ImageSizing(tifEditor.Viewer); int degree = (direction == FlipDirection.Left) ? -1:1; imageSize.RotateImageAndAnnotations(degree * 90, tifEditor.AnnAutomation.Container); }
/// <inheritdoc /> public Bitmap FlipImage(Bitmap original, RectangleCoords resultCoords, FlipDirection dir) { // Так как при отражении итоговые размеры картинки не меняются, имеем право сразу узнать // координаты итоговой области. if (!resultCoords.IntersectWith(original.Width, original.Height)) { return(null); } resultCoords.Intersect(original.Width, original.Height); switch (dir) { case FlipDirection.Horizontal: original.RotateFlip(RotateFlipType.RotateNoneFlipX); break; case FlipDirection.Vertical: original.RotateFlip(RotateFlipType.RotateNoneFlipY); break; default: throw new ArgumentException("Invalid Flip direction"); } return(original.Clone( new Rectangle( resultCoords.X, resultCoords.Y, resultCoords.Width, resultCoords.Height), original.PixelFormat)); }
public static Rectangle ToRectangle(this FlipDirection direction, int width, int height) { switch (direction) { case FlipDirection.Horizontal: return(new Rectangle( left: 0, top: height, right: width, bottom: 0)); case FlipDirection.Vertical: return(new Rectangle( left: width, top: 0, right: 0, bottom: height)); case FlipDirection.Both: return(new Rectangle( left: width, top: height, right: 0, bottom: 0)); default: throw new Exception($"Unsupported flip direction: {direction}"); } }
/** * The {@code FlipDirection} enumeration defines the most typical flip view transitions: left-to-right and right-to-left. {@code FlipDirection} is used during the creation of {@link FlipAnimation} animations. * * @author Ephraim A. Tekle * */ /** * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in transition. * * NOTE: Avoid using this method. Instead, use {@link #flipTransition}. * * @param fromView the view transition away from * @param toView the view transition to * @param dir the flip direction * @param duration the transition duration in milliseconds * @param interpolator the interpolator to use (pass {@code null} to use the {@link AccelerateInterpolator} interpolator) * @return */ public static Animation[] FlipAnimation(View fromView, View toView, FlipDirection dir, long duration, IInterpolator interpolator) { Animation[] result = new Animation[2]; float centerX; float centerY; centerX = fromView.Width / 2.0f; centerY = fromView.Height / 2.0f; FlipAnimation outFlip = new FlipAnimation(0, dir.EndDegreeForFirstView(), centerX, centerY, SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleDown); outFlip.Duration = duration; outFlip.FillAfter = true; outFlip.Interpolator = interpolator ?? new AccelerateInterpolator(); if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom) { outFlip.Direction = Direction.X; } else { outFlip.Direction = Direction.Y; } AnimationSet outAnimation = new AnimationSet(true); outAnimation.AddAnimation(outFlip); result[0] = outAnimation; // Uncomment the following if toView has its layout established (not the case if using ViewFlipper and on first show) //centerX = toView.getWidth() / 2.0f; //centerY = toView.getHeight() / 2.0f; FlipAnimation inFlip = new FlipAnimation(dir.StartDegreeForSecondView(), 0, centerX, centerY, SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleUp); inFlip.Duration = duration; inFlip.FillAfter = true; inFlip.StartOffset = duration; inFlip.Interpolator = interpolator ?? new AccelerateInterpolator(); if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom) { outFlip.Direction = Direction.X; } else { outFlip.Direction = Direction.Y; } AnimationSet inAnimation = new AnimationSet(true); inAnimation.AddAnimation(inFlip); result[1] = inAnimation; return(result); }
protected override void Telegrafar(Vector3 charPos) { FlipDirection.Flip(transform, charPos.x - transform.position.x); InstanciaLigando.Instantiate(particulaTelegrafista, transform.position, 5); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.Wind1)); }
private static void FlipTiles(bool Individual, FlipDirection Direction) { Methods.Solution.CurrentSolution.EditLayerA?.FlipPropertySelected(Direction, Individual); Methods.Solution.CurrentSolution.EditLayerB?.FlipPropertySelected(Direction, Individual); Methods.Solution.CurrentSolution.EditLayerC?.FlipPropertySelected(Direction, Individual); Methods.Solution.CurrentSolution.EditLayerD?.FlipPropertySelected(Direction, Individual); ManiacEditor.Actions.UndoRedoModel.UpdateEditLayersActions(); }
protected override void DoFlip(FlipDirection flipDirection) { if (flipDirection != FlipDirection.Revert) { UnregisterManipulations(); TurnPage(flipDirection == FlipDirection.Forward); } }
protected override void ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { double totalManipulation = (e.TotalManipulation.Translation.X + e.FinalVelocities.LinearVelocity.X / 20); FlipDirection flipDirection = totalManipulation > DRAG_THRESHOLD ? FlipDirection.Backward : totalManipulation < -DRAG_THRESHOLD ? FlipDirection.Forward : FlipDirection.Revert; DoFlip(flipDirection); }
void MyFlip() { if (transform) { x2 = x1; x1 = transform.position.x; FlipDirection.Flip(transform, x1 - x2); Invoke("MyFlip", 0.5f); } }
/// <summary> /// Flips an input image horizontally / vertically / both directions / or none (data copy). /// </summary> /// <typeparam name="TColor">Color type.</typeparam> /// <param name="source">Input image.</param> /// <param name="flipDirection">Flip direction.</param> /// <returns>Returns flipped image.</returns> public static TColor[,] FlipImage <TColor>(this TColor[,] source, FlipDirection flipDirection) where TColor : struct { TColor[,] dest = source.CopyBlank(); var sourceArea = new Rectangle(0, 0, source.Width(), source.Height()); var destinationOffset = new Point(); source.FlipImage(sourceArea, dest, destinationOffset, flipDirection); return(dest); }
/* * protected void RetornarParaEsperaZerandoTempo() * { * //estado = EstadoDaqui.emEspera; * tempoDecorrido = 0; * //VerifiquePosicionamento(); * }*/ void SimTelegrafar(Vector3 charPos) { new MyInvokeMethod().InvokeNoTempoDeJogo(gameObject, () => { RequestAction(charPos); }, tempoTelegrafando); FlipDirection.Flip(transform, charPos.x - transform.position.x); _Animator.SetTrigger("action"); // RetornarParaEsperaZerandoTempo(); }
public static FlipType ToOpenCVFlipType(FlipDirection flip) { return(flip switch { FlipDirection.None => throw new NotSupportedException($"Flip type: {flip} is not supported by OpenCV."), FlipDirection.Horizontally => FlipType.Horizontal, FlipDirection.Vertically => FlipType.Vertical, FlipDirection.Both => FlipType.Both, _ => throw new ArgumentOutOfRangeException(nameof(flip), flip, null) });
protected override void RequestAction(Vector3 charPos) { FlipDirection.Flip(transform, charPos.x - transform.position.x); InstanciaLigando.Instantiate(particulaDoSpawn, transform.position, 5); GameObject G = InstanciaLigando.Instantiate(breed, transform.position); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.lancaProjetilInimigo)); spawnados.Add(G); RetornarParaEsperaZerandoTempo(); }
protected override void ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { FlipDirection direction = e.CumulativeManipulation.Translation.X > 0 ? FlipDirection.Backward : FlipDirection.Forward; UpdateLayers(direction); var src = (Canvas)sender; var transform = (TranslateTransform)src.RenderTransform; transform.X += e.DeltaManipulation.Translation.X; }
/// <summary> /// Flips an input image horizontally / vertically / both directions / or none (data copy). /// </summary> /// <param name="img">Input image.</param> /// <param name="flip">Flip direction.</param> /// <param name="inPlace">Do it in place.</param> /// <returns>Returns flipped image. If <paramref name="inPlace"/> was set to true the result can be omitted.</returns> public static IImage FlipImage(this IImage img, FlipDirection flip, bool inPlace = false) { IImage dest = img; if (!inPlace) { dest = img.CopyBlank(); } FlipImage((IImage)img, dest, flip); return(dest); }
IEnumerator ResetFlippingState(FlipDirection direction) { if (!IsFlipping) { yield break; } if (direction == FlipDirection.Next) { OddPageMaterials[0].mainTexture = Pages[currentPage - 1]; if (currentPage < Pages.Count) { OddPageMaterials[1].mainTexture = Pages[currentPage]; } } else if (currentPage > 1) { EvenPageMaterials[0].mainTexture = Pages[currentPage - 3]; EvenPageMaterials[1].mainTexture = Pages[currentPage - 2]; EvenPageHolder.SetActive(true); } else { EvenPageHolder.SetActive(false); } yield return(new WaitForSeconds(animationDurationInSeconds)); if (currentPage == 1) { EvenPageHolder.SetActive(false); } else { EvenPageMaterials[0].mainTexture = Pages[currentPage - 3]; EvenPageMaterials[1].mainTexture = Pages[currentPage - 2]; EvenPageHolder.SetActive(true); } if (direction == FlipDirection.Previous) { OddPageMaterials[0].mainTexture = Pages[currentPage - 1]; if (currentPage < Pages.Count) { OddPageMaterials[1].mainTexture = Pages[currentPage]; } } GetComponent <AudioSource>().enabled = false; PageFlipAnimator.SetTrigger(IdleStateTriggerName); IsFlipping = false; }
protected override void UpdateLayers(FlipDirection direction) { if (direction == FlipDirection.Backward) { Canvas.SetZIndex(GetPrevPagePanel(), 5); Canvas.SetZIndex(GetNextPagePanel(), 0); } else if (direction == FlipDirection.Forward) { Canvas.SetZIndex(GetNextPagePanel(), 5); Canvas.SetZIndex(GetPrevPagePanel(), 0); } }
/// <summary> /// Start a new animation to swing around to the other side of the puzzle board. /// </summary> /// <param name="direction">Direction to move the camera.</param> public void Flip(FlipDirection direction) { side = (side == BoardSide.Front) ? BoardSide.Back : BoardSide.Front; baseXZ += (float)Math.PI * (int)direction; previousXZ = currentXZ; targetXZ = baseXZ; cameraMovementCurrentTime = 0.0f; cameraMovementTotalTime = 0.6f; Audio.Play("Flip Board"); isFlipping = true; }
/// <summary> /// Flips an input image horizontally / vertically / both directions / or none (data copy). /// </summary> /// <param name="srcImg">Source image.</param> /// <param name="dstImg">DEstination image. Must have the same size as source image.</param> /// <param name="flip">Flip direction.</param> public static void FlipImage(IImage srcImg, IImage dstImg, FlipDirection flip) { Type channelType = srcImg.ColorInfo.ChannelType; ImageFlipFunc flipFunc = null; if (imageFlipFuncs.TryGetValue(channelType, out flipFunc) == false) { throw new Exception(string.Format("FlipImage can no process an image of type {0}", channelType)); } flipFunc(srcImg, dstImg, flip); }
protected override void DoFlip(FlipDirection flipDirection) { double currentTranslationX = ((TranslateTransform)GetCurrentPagePanel().RenderTransform).X; double leftToAnimate; switch (flipDirection) { case FlipDirection.Forward: leftToAnimate = -(Screen.Width + currentTranslationX); break; case FlipDirection.Backward: leftToAnimate = Screen.Width - currentTranslationX; break; case FlipDirection.Revert: leftToAnimate = -currentTranslationX; break; default: throw new NotSupportedException(); } var storyboard = new Storyboard(); foreach (Panel panel in Panels) { var doubleTranslateAnimation = new DoubleAnimation { By = leftToAnimate, Duration = new Duration(TimeSpan.FromMilliseconds(250)), EasingFunction = new SineEase() }; Storyboard.SetTarget(doubleTranslateAnimation, panel.RenderTransform); Storyboard.SetTargetProperty(doubleTranslateAnimation, new PropertyPath("X")); storyboard.Children.Add(doubleTranslateAnimation); } if (flipDirection != FlipDirection.Revert) { UnregisterManipulations(); storyboard.Completed += delegate { TurnPage(flipDirection == FlipDirection.Forward); }; } storyboard.Begin(); }
internal void Flip(FlipDirection flipDirection) { if (entity.attributesMap.ContainsKey("flipFlag")) { if (flipDirection == FlipDirection.Horizontal) { entity.attributesMap["flipFlag"].ValueVar ^= 0x01; } else { entity.attributesMap["flipFlag"].ValueVar ^= 0x02; } } }
/// <summary> /// Flip video background /// </summary> /// <param name="direction">Flip direction</param> /// <param name="on">True to set. False to rest</param> public void FlipVideo(FlipDirection direction, bool on) { NativeAPI.CameraDevice_flipVideo((int)direction, on); if (direction == FlipDirection.HORIZONTAL) { flipHorizontal = on; } if (direction == FlipDirection.VERTICAL) { flipVertical = on; } }
public void Flip(FlipDirection direction) { if (IsFlipping) { Debug.Log("Flipping already in progress"); return; } if (!CanFlip(direction)) { Debug.Log("Cannot flip further"); return; } IsFlipping = true; int newPage = currentPage; int indexOfRequiredPage = currentPage; if (direction == FlipDirection.Next) { newPage += 2; indexOfRequiredPage = currentPage - 1; } else { newPage -= 2; indexOfRequiredPage = newPage - 1; } foreach (GameObject frame in AnimationKeyFrames) { Material[] materials = frame.GetComponent <Renderer>().materials; materials[0].mainTexture = Pages[indexOfRequiredPage]; if (currentPage < Pages.Count) { materials[1].mainTexture = Pages[indexOfRequiredPage + 1]; } } currentPage = newPage; // Trigger Animation PageFlipAnimator.SetBool(IsDirectionForwardParameterName, direction == FlipDirection.Next); PageFlipAnimator.SetTrigger(FlipAnimationTriggerName); GetComponent <AudioSource>().enabled = true; StartCoroutine(ResetFlippingState(direction)); }
/** * Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will initiate a {@link FlipAnimation} to show the next View. * If the currently visible view is the last view, flip direction will be reversed for this transition. * * @param viewAnimator the {@code ViewAnimator} * @param dir the direction of flip * @param duration the transition duration in milliseconds */ public static void FlipTransition(ViewAnimator viewAnimator, FlipDirection dir, long duration) { View fromView = viewAnimator.CurrentView; int currentIndex = viewAnimator.DisplayedChild; int nextIndex = (currentIndex + 1) % viewAnimator.ChildCount; View toView = viewAnimator.GetChildAt(nextIndex); Animation[] animc = AnimationFactory.FlipAnimation(fromView, toView, (nextIndex < currentIndex ? dir.OtherDirection() : dir), duration, new AnticipateOvershootInterpolator()); viewAnimator.OutAnimation = animc[0]; viewAnimator.InAnimation = animc[1]; viewAnimator.ShowNext(); }
public static float EndDegreeForFirstView(this FlipDirection direction) { switch (direction) { case FlipDirection.LeftRight: case FlipDirection.TopBottom: return(90); case FlipDirection.RightLeft: case FlipDirection.BottomTop: return(-90); default: return(0); } }
public static RotateFlipType ToRotateFlipType(this FlipDirection direction) { switch (direction) { case FlipDirection.Both: return(RotateFlipType.RotateNoneFlipXY); case FlipDirection.Horizontal: return(RotateFlipType.RotateNoneFlipX); case FlipDirection.Vertical: return(RotateFlipType.RotateNoneFlipY); default: throw new Exception($"Unsupported flip direction: {direction}"); } }
protected override void DoFlip(FlipDirection flipDirection) { double currentTranslationX = ((TranslateTransform) GetCurrentPagePanel().RenderTransform).X; double leftToAnimate; switch (flipDirection) { case FlipDirection.Forward: leftToAnimate = -(Screen.Width + currentTranslationX); break; case FlipDirection.Backward: leftToAnimate = Screen.Width - currentTranslationX; break; case FlipDirection.Revert: leftToAnimate = -currentTranslationX; break; default: throw new NotSupportedException(); } var storyboard = new Storyboard(); foreach (Panel panel in Panels) { var doubleTranslateAnimation = new DoubleAnimation { By = leftToAnimate, Duration = new Duration(TimeSpan.FromMilliseconds(250)), EasingFunction = new SineEase() }; Storyboard.SetTarget(doubleTranslateAnimation, panel.RenderTransform); Storyboard.SetTargetProperty(doubleTranslateAnimation, new PropertyPath("X")); storyboard.Children.Add(doubleTranslateAnimation); } if (flipDirection != FlipDirection.Revert) { UnregisterManipulations(); storyboard.Completed += delegate { TurnPage(flipDirection == FlipDirection.Forward); }; } storyboard.Begin(); }
protected override void DoFlip(FlipDirection flipDirection) { var sb = new Storyboard(); var da = new DoubleAnimation { Duration = new Duration(TimeSpan.FromMilliseconds(250)), EasingFunction = new SineEase() }; switch (flipDirection) { case FlipDirection.Forward: da.To = -Screen.Width; break; case FlipDirection.Backward: da.To = Screen.Width; break; case FlipDirection.Revert: da.To = 0; break; default: throw new NotSupportedException(); } var transform = (TranslateTransform) GetCurrentPagePanel().RenderTransform; Storyboard.SetTarget(da, transform); Storyboard.SetTargetProperty(da, new PropertyPath("X")); sb.Children.Add(da); if (flipDirection != FlipDirection.Revert) { UnregisterManipulations(); sb.Completed += delegate { TurnPage(flipDirection == FlipDirection.Forward); }; } sb.Begin(); }
public void Flip( FlipDirection direction ) { side = ( side == BoardSide.Front ) ? BoardSide.Back : BoardSide.Front; baseXZ += (float)Math.PI * (int)direction; previousXZ = currentXZ; targetXZ = baseXZ; cameraMovementCurrentTime = 0.0f; cameraMovementTotalTime = 0.6f; Audio.Play( "Flip Board" ); isFlipping = true; }
static DoubleAnimation MakeRotationAnimation(PlaneProjection planeProjection, FlipAxis axis, FlipDirection direction, Duration duration) { DoubleAnimation da = new DoubleAnimation(); da.Duration = duration; switch (axis) { case FlipAxis.Vertical: da.By = direction == FlipDirection.Backwards ? -90 : 90; break; case FlipAxis.Horizontal: da.By = direction == FlipDirection.Backwards ? 90 : -90; break; default: break; } Storyboard.SetTarget(da, planeProjection); Storyboard.SetTargetProperty(da, new PropertyPath( axis == FlipAxis.Vertical ? "RotationX" : "RotationY")); return (da); }
/** * The {@code FlipDirection} enumeration defines the most typical flip view transitions: left-to-right and right-to-left. {@code FlipDirection} is used during the creation of {@link FlipAnimation} animations. * * @author Ephraim A. Tekle * */ /** * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in transition. * * NOTE: Avoid using this method. Instead, use {@link #flipTransition}. * * @param fromView the view transition away from * @param toView the view transition to * @param dir the flip direction * @param duration the transition duration in milliseconds * @param interpolator the interpolator to use (pass {@code null} to use the {@link AccelerateInterpolator} interpolator) * @return */ public static Animation[] FlipAnimation(View fromView, View toView, FlipDirection dir, long duration, IInterpolator interpolator) { Animation[] result = new Animation[2]; float centerX; float centerY; centerX = fromView.Width/2.0f; centerY = fromView.Height/2.0f; FlipAnimation outFlip = new FlipAnimation(0, dir.EndDegreeForFirstView(), centerX, centerY, SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleDown); outFlip.Duration = duration; outFlip.FillAfter = true; outFlip.Interpolator = interpolator ?? new AccelerateInterpolator(); if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom) outFlip.Direction = Direction.X; else outFlip.Direction = Direction.Y; AnimationSet outAnimation = new AnimationSet(true); outAnimation.AddAnimation(outFlip); result[0] = outAnimation; // Uncomment the following if toView has its layout established (not the case if using ViewFlipper and on first show) //centerX = toView.getWidth() / 2.0f; //centerY = toView.getHeight() / 2.0f; FlipAnimation inFlip = new FlipAnimation(dir.StartDegreeForSecondView(), 0, centerX, centerY, SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleUp); inFlip.Duration = duration; inFlip.FillAfter = true; inFlip.StartOffset = duration; inFlip.Interpolator = interpolator ?? new AccelerateInterpolator(); if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom) outFlip.Direction = Direction.X; else outFlip.Direction = Direction.Y; AnimationSet inAnimation = new AnimationSet(true); inAnimation.AddAnimation(inFlip); result[1] = inAnimation; return result; }
/** * Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will initiate a {@link FlipAnimation} to show the next View. * If the currently visible view is the last view, flip direction will be reversed for this transition. * * @param viewAnimator the {@code ViewAnimator} * @param dir the direction of flip * @param duration the transition duration in milliseconds */ public static void FlipTransition(ViewAnimator viewAnimator, FlipDirection dir, long duration) { View fromView = viewAnimator.CurrentView; int currentIndex = viewAnimator.DisplayedChild; int nextIndex = (currentIndex + 1)%viewAnimator.ChildCount; View toView = viewAnimator.GetChildAt(nextIndex); Animation[] animc = AnimationFactory.FlipAnimation(fromView, toView, (nextIndex < currentIndex ? dir.OtherDirection() : dir), duration, new AnticipateOvershootInterpolator()); viewAnimator.OutAnimation = animc[0]; viewAnimator.InAnimation = animc[1]; viewAnimator.ShowNext(); }
/// <summary> /// Sets the tiles flipping mode. /// </summary> /// <param name="direction">The desired direction to flip.</param> public void Flip(FlipDirection direction) { // Set flipping enumeration. switch (_flip) { case FlipType.None: // If flipping horizontally. if (direction == FlipDirection.Horizontal) _flip = FlipType.Horizontal; else _flip = FlipType.Vertical; break; case FlipType.Horizontal: // If flipping horizontally. if (direction == FlipDirection.Horizontal) _flip = FlipType.None; else _flip = FlipType.Both; break; case FlipType.Vertical: // If flipping horizontally. if (direction == FlipDirection.Horizontal) _flip = FlipType.Both; else _flip = FlipType.None; break; case FlipType.Both: // If flipping horizontally. if (direction == FlipDirection.Horizontal) _flip = FlipType.Vertical; else _flip = FlipType.Horizontal; break; } }
/// <summary> /// 设置进入和离开对象 /// </summary> /// <param name="flipSrc">转出对象</param> /// <param name="flipDst">转入对象</param> /// <param name="flipDir">翻转方向</param> public void FlipTo(Control flipSrc, Control flipDst, FlipDirection flipDir) { _PlaneSrc = new PlaneProjection(); _PlaneDst = new PlaneProjection(); flipSrc.Projection = _PlaneSrc; if (flipDst.Visibility != Visibility.Visible) { flipDst.Width = flipSrc.ActualWidth; flipDst.Height = flipSrc.ActualHeight; flipDst.Visibility = Visibility.Visible; } flipDst.Projection = _PlaneDst; if (flipDir == FlipDirection.Left || flipDir == FlipDirection.Right) { _OffsetZSrc = flipSrc.ActualWidth / 2; _OffsetZDst = flipDst.ActualWidth / 2; } else { _OffsetZSrc = flipSrc.ActualHeight / 2; _OffsetZDst = flipDst.ActualHeight / 2; } _Direction = flipDir; InitFlipData(); }
/** * Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will initiate a {@link FlipAnimation} to show the next View. * If the currently visible view is the last view, flip direction will be reversed for this transition. * * @param viewAnimator the {@code ViewAnimator} * @param dir the direction of flip */ public static void FlipTransition(ViewAnimator viewAnimator, FlipDirection dir) { FlipTransition(viewAnimator, dir, _defaultFlipTransitionDuration); }
protected virtual void UpdateLayers(FlipDirection direction) { }
protected abstract void DoFlip(FlipDirection direction);