private Timeline CreateExpandIn(ITransitionEffectSubject effectSubject) { var scaleXAnimation = new DoubleAnimationUsingKeyFrames(); var zeroFrame = new DiscreteDoubleKeyFrame(0.0); var startFrame = new DiscreteDoubleKeyFrame(.5, effectSubject.Offset + OffsetTime); var endFrame = new EasingDoubleKeyFrame(1, effectSubject.Offset + OffsetTime + Duration) { EasingFunction = new SineEase() }; scaleXAnimation.KeyFrames.Add(zeroFrame); scaleXAnimation.KeyFrames.Add(startFrame); scaleXAnimation.KeyFrames.Add(endFrame); Storyboard.SetTargetName(scaleXAnimation, effectSubject.ScaleTransformName); Storyboard.SetTargetProperty(scaleXAnimation, new PropertyPath(ScaleTransform.ScaleXProperty)); var scaleYAnimation = scaleXAnimation.Clone(); Storyboard.SetTargetName(scaleYAnimation, effectSubject.ScaleTransformName); Storyboard.SetTargetProperty(scaleYAnimation, new PropertyPath(ScaleTransform.ScaleYProperty)); var parallelTimeline = new ParallelTimeline(); parallelTimeline.Children.Add(scaleXAnimation); parallelTimeline.Children.Add(scaleYAnimation); return(parallelTimeline); }
private void KeyCounterAdd() { c_step = 2; parent.lbl_KS_Step.Content = typeof(PRESENT).GetPluginStringResource(steps[c_step]); int a, b, r, x; a = (int)(parent.cipher.KeyRegs[c_round, 1, 3] & 0xf) << 1; b = (int)(parent.cipher.KeyRegs[c_round, 0, 3] >> 15) & 1; r = a ^ b; parent.lbl_KS_Text.Content = String.Format(Properties.Resources.xor_round_counter, Int2BinaryString(a, 5), Int2BinaryString(b, 5), Int2BinaryString(r, 5)); TranslateTransform3D tt = new TranslateTransform3D(); for (int i = 0; i < 5; i++) { x = (r >> i) & 1; gma3D_roundcountertemp[i].Material = gma3D_keyreg[i + 15].Material; gma3D_roundcountertemp[i].Transform = tt; gma3D_keyreg[i + 15].Material = material[x, 3]; } CosDoubleAnimation day = new CosDoubleAnimation() { From = Math.PI * 3 / 2, To = Math.PI * 2, Scale = 0.6, Duration = TimeSpan.FromSeconds(2), SpeedRatio = parent.sld_KS_Speed.Value }; DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames() { Duration = TimeSpan.FromSeconds(4), SpeedRatio = parent.sld_KS_Speed.Value }; da.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0))); da.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0.5))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_default, KeyTime.FromPercent(1))); DoubleAnimationUsingKeyFrames db = da.Clone(); brush[0, 3].BeginAnimation(Brush.OpacityProperty, da); brush[1, 3].BeginAnimation(Brush.OpacityProperty, db); tt.BeginAnimation(TranslateTransform3D.OffsetYProperty, day); countdown(4, MethodBase.GetCurrentMethod().Name); }
void KeyGetRoundKeyGroup() { int x; for (int i = 0; i < 64; i++) { x = (int)(parent.cipher.KeyRegs[c_round, 1, 3] >> i) & 1; if (i >= (c_group * 4) && i < ((c_group + 1) * 4)) { gma3D_roundkeys[c_round, i].Material = material[x, 1]; gma3D_keyreg[i + 16].Material = material[x, 1]; } else { if (i < (c_group * 4)) { gma3D_roundkeys[c_round, i].Material = material[x, 0]; gma3D_keyreg[i + 16].Material = material[x, 2]; } } } DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames() { Duration = TimeSpan.FromSeconds(1), SpeedRatio = parent.sld_KS_Speed.Value }; da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_low, KeyTime.FromPercent(0))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_high, KeyTime.FromPercent(0.25))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_high, KeyTime.FromPercent(0.75))); da.KeyFrames.Add(new LinearDoubleKeyFrame(opacity_low, KeyTime.FromPercent(1))); DoubleAnimationUsingKeyFrames db = da.Clone(); brush[0, 1].BeginAnimation(Brush.OpacityProperty, da); brush[1, 1].BeginAnimation(Brush.OpacityProperty, db); countdown(1, MethodBase.GetCurrentMethod().Name); }
private static void AddAnimatedWalkCycle( TranslateTransform3D hipPosition, RotateTransform3D leftLegRotation, RotateTransform3D leftKneeRotation, RotateTransform3D leftAnkleRotation, RotateTransform3D rightLegRotation, RotateTransform3D rightKneeRotation, RotateTransform3D rightAnkleRotation, int durationInMs) { DoubleAnimationUsingKeyFrames leftLegRotationAnimation = new DoubleAnimationUsingKeyFrames(); leftLegRotationAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(durationInMs)); leftLegRotationAnimation.AutoReverse = false; leftLegRotationAnimation.RepeatBehavior = RepeatBehavior.Forever; // Clone all rotations DoubleAnimationUsingKeyFrames leftKneeRotationAnimation = leftLegRotationAnimation.Clone(); DoubleAnimationUsingKeyFrames leftAnkleRotationAnimation = leftLegRotationAnimation.Clone(); DoubleAnimationUsingKeyFrames rightLegRotationAnimation = leftLegRotationAnimation.Clone(); DoubleAnimationUsingKeyFrames rightKneeRotationAnimation = leftLegRotationAnimation.Clone(); DoubleAnimationUsingKeyFrames rightAnkleRotationAnimation = leftLegRotationAnimation.Clone(); DoubleAnimationUsingKeyFrames hipPositionAnimation = new DoubleAnimationUsingKeyFrames(); hipPositionAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(durationInMs)); hipPositionAnimation.AutoReverse = false; hipPositionAnimation.RepeatBehavior = RepeatBehavior.Forever; DoubleKeyFrame current; // top leg keys DoubleKeyFrame topTipContact = new LinearDoubleKeyFrame(40); DoubleKeyFrame topCrossOverBent = new LinearDoubleKeyFrame(-25); DoubleKeyFrame topAnkleContact = new LinearDoubleKeyFrame(-40); DoubleKeyFrame topCrossOverStraight = new LinearDoubleKeyFrame(0); // knee leg keys DoubleKeyFrame kneeStraight = new LinearDoubleKeyFrame(0); DoubleKeyFrame kneeBent = new LinearDoubleKeyFrame(130); // ankle keys DoubleKeyFrame ankleTipContact = new LinearDoubleKeyFrame(40); DoubleKeyFrame ankleCrossOverBent = new LinearDoubleKeyFrame(0); DoubleKeyFrame ankleAnkleContact = new LinearDoubleKeyFrame(-30); DoubleKeyFrame ankleGroundContact = new LinearDoubleKeyFrame(10); DoubleKeyFrame ankleCrossOverStraight = new LinearDoubleKeyFrame(0); // Left leg - top segment current = (DoubleKeyFrame)topTipContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.0); leftLegRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)topCrossOverBent.Clone(); current.KeyTime = KeyTime.FromPercent(0.25); leftLegRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)topAnkleContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.5); leftLegRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)topCrossOverStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.75); leftLegRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)topTipContact.Clone(); current.KeyTime = KeyTime.FromPercent(1.0); leftLegRotationAnimation.KeyFrames.Add(current); leftLegRotation.Rotation.BeginAnimation( AxisAngleRotation3D.AngleProperty, leftLegRotationAnimation); // Right leg - top segment current = (DoubleKeyFrame)topAnkleContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.0); rightLegRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)topCrossOverStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.25); rightLegRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)topTipContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.5); rightLegRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)topCrossOverBent.Clone(); current.KeyTime = KeyTime.FromPercent(0.75); rightLegRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)topAnkleContact.Clone(); current.KeyTime = KeyTime.FromPercent(1); rightLegRotationAnimation.KeyFrames.Add(current); rightLegRotation.Rotation.BeginAnimation( AxisAngleRotation3D.AngleProperty, rightLegRotationAnimation); // Left leg - knee segment current = (DoubleKeyFrame)kneeStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.0); leftKneeRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)kneeBent.Clone(); current.KeyTime = KeyTime.FromPercent(0.25); leftKneeRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)kneeStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.5); leftKneeRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)kneeStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.75); leftKneeRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)kneeStraight.Clone(); current.KeyTime = KeyTime.FromPercent(1.0); leftKneeRotationAnimation.KeyFrames.Add(current); leftKneeRotation.Rotation.BeginAnimation( AxisAngleRotation3D.AngleProperty, leftKneeRotationAnimation); // Right leg - knee segment current = (DoubleKeyFrame)kneeStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.0); rightKneeRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)kneeStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.25); rightKneeRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)kneeStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.5); rightKneeRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)kneeBent.Clone(); current.KeyTime = KeyTime.FromPercent(0.75); rightKneeRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)kneeStraight.Clone(); current.KeyTime = KeyTime.FromPercent(1); rightKneeRotationAnimation.KeyFrames.Add(current); rightKneeRotation.Rotation.BeginAnimation( AxisAngleRotation3D.AngleProperty, rightKneeRotationAnimation); // Left leg - ankle segment current = (DoubleKeyFrame)ankleTipContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.0); leftAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleCrossOverBent.Clone(); current.KeyTime = KeyTime.FromPercent(0.25); leftAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleAnkleContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.5); leftAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleGroundContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.625); leftAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleCrossOverStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.75); leftAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleTipContact.Clone(); current.KeyTime = KeyTime.FromPercent(1.0); leftAnkleRotationAnimation.KeyFrames.Add(current); leftAnkleRotation.Rotation.BeginAnimation( AxisAngleRotation3D.AngleProperty, leftAnkleRotationAnimation); // Right leg - ankle segment current = (DoubleKeyFrame)ankleAnkleContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.0); rightAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleGroundContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.125); rightAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleCrossOverStraight.Clone(); current.KeyTime = KeyTime.FromPercent(0.25); rightAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleTipContact.Clone(); current.KeyTime = KeyTime.FromPercent(0.5); rightAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleCrossOverBent.Clone(); current.KeyTime = KeyTime.FromPercent(0.75); rightAnkleRotationAnimation.KeyFrames.Add(current); current = (DoubleKeyFrame)ankleAnkleContact.Clone(); current.KeyTime = KeyTime.FromPercent(1); rightAnkleRotationAnimation.KeyFrames.Add(current); rightAnkleRotation.Rotation.BeginAnimation( AxisAngleRotation3D.AngleProperty, rightAnkleRotationAnimation); // Body DoubleKeyFrame currentPosition; // body keys DoubleKeyFrame bodyDown = new LinearDoubleKeyFrame(0); DoubleKeyFrame bodyUp = new LinearDoubleKeyFrame(0.125); currentPosition = (DoubleKeyFrame)bodyDown.Clone(); currentPosition.KeyTime = KeyTime.FromPercent(0.0); hipPositionAnimation.KeyFrames.Add(currentPosition); currentPosition = (DoubleKeyFrame)bodyUp.Clone(); currentPosition.KeyTime = KeyTime.FromPercent(0.25); hipPositionAnimation.KeyFrames.Add(currentPosition); currentPosition = (DoubleKeyFrame)bodyDown.Clone(); currentPosition.KeyTime = KeyTime.FromPercent(0.5); hipPositionAnimation.KeyFrames.Add(currentPosition); currentPosition = (DoubleKeyFrame)bodyUp.Clone(); currentPosition.KeyTime = KeyTime.FromPercent(0.75); hipPositionAnimation.KeyFrames.Add(currentPosition); currentPosition = (DoubleKeyFrame)bodyDown.Clone(); currentPosition.KeyTime = KeyTime.FromPercent(1.0); hipPositionAnimation.KeyFrames.Add(currentPosition); hipPosition.BeginAnimation(TranslateTransform3D.OffsetYProperty, hipPositionAnimation); }
/// <summary> /// Creates a new instance of a HappyWordAnimation. Initializes the animation based on the /// specified paramaters. /// </summary> /// <param name="w">The CaptionWord to base the animation off of.</param> /// begins.</param> /// <param name="t">The Textblock that this animation will be applied to.</param> public HappyWordAnimation(CaptionWord w, CaptionTextBlock t) : base(w, t) { //Settings dependent on intensity double dur = 0; double scalefinish = 0; double yFinish = 0; switch (w.Intensity) { case Intensity.Low: dur = 0.75; scalefinish = 1.1; yFinish = 20; break; case Intensity.Medium: dur = 0.65; scalefinish = 1.2; yFinish = 40; break; case Intensity.High: dur = 0.60; scalefinish = 1.3; yFinish = 40; break; case Intensity.None: default: //TODO handle exception break; } //Animation duration Duration duration = TimeSpan.FromSeconds(dur); StringBuilder b = new StringBuilder(t.Caption.Text); //Formatted text up until the index of the caption var captionFT = new FormattedText ( b.ToString(0, w.BeginIndex), CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface(t.FontFamily, t.FontStyle, t.FontWeight, t.FontStretch), t.FontSize, Brushes.Black //Colour does not matter here ); //Formatted text of the emotive caption word var wordFT = new FormattedText ( w.Text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface(t.FontFamily, t.FontStyle, t.FontWeight, t.FontStretch), t.FontSize, Brushes.Black //Colour does not matter here ); TextEffect e1 = new TextEffect { PositionStart = w.BeginIndex, PositionCount = w.Length, Transform = new ScaleTransform { //TODO: Fix centering CenterX = captionFT.Width + wordFT.Width / 2, CenterY = captionFT.Height, }, }; this.TextEffects.Add(e1); DoubleAnimationUsingKeyFrames a1 = new DoubleAnimationUsingKeyFrames { BeginTime = TimeSpan.FromSeconds(t.Caption.Begin), Duration = duration, }; a1.KeyFrames.Add(new LinearDoubleKeyFrame(0.5, KeyTime.FromPercent(0))); a1.KeyFrames.Add(new LinearDoubleKeyFrame(scalefinish, KeyTime.FromPercent(0.5))); a1.KeyFrames.Add(new LinearDoubleKeyFrame(1, KeyTime.FromPercent(1))); this.Animations.Add(a1); this.AnimationTargets.Add(new AnimationTargetString("Transform.ScaleX", 0)); //Make second animation for y scale DoubleAnimationUsingKeyFrames a2 = a1.Clone(); this.Animations.Add(a2); this.AnimationTargets.Add(new AnimationTargetString("Transform.ScaleY", 0)); TextEffect e2 = new TextEffect //Yfinish effect { PositionStart = w.BeginIndex, PositionCount = w.Length, Transform = new TranslateTransform(), }; this.TextEffects.Add(e2); DoubleAnimationUsingKeyFrames a3 = new DoubleAnimationUsingKeyFrames { BeginTime = TimeSpan.FromSeconds(t.Caption.Begin), Duration = duration, }; a3.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0))); a3.KeyFrames.Add(new LinearDoubleKeyFrame(-yFinish, KeyTime.FromPercent(0.5))); a3.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(1))); this.Animations.Add(a3); this.AnimationTargets.Add(new AnimationTargetString("Transform.Y", 1)); //alpha effect TextEffect e3 = new TextEffect() { PositionStart = w.BeginIndex, PositionCount = w.Length, }; e3.Foreground = t.Foreground; this.TextEffects.Add(e3); ColorAnimationUsingKeyFrames a4 = new ColorAnimationUsingKeyFrames { BeginTime = TimeSpan.FromSeconds(t.Caption.Begin), Duration = duration, }; System.Windows.Media.Color fgColor = t.Caption.Speaker.Font.ForegroundColour.ToMediaColor(); a4.KeyFrames.Add(new LinearColorKeyFrame(fgColor, KeyTime.FromPercent(0))); a4.KeyFrames.Add(new LinearColorKeyFrame(Color.FromArgb(100, fgColor.R, fgColor.G, fgColor.B), KeyTime.FromPercent(0.5))); a4.KeyFrames.Add(new LinearColorKeyFrame(fgColor, KeyTime.FromPercent(1))); this.Animations.Add(a4); this.AnimationTargets.Add(new AnimationTargetString("Foreground." + SolidColorBrush.ColorProperty.ToString(), 2)); }