Forum > Coding >

[RELEASE] Terrible animator class from 17 centuries ago

SeizureSalad

i love femboys

Posts: 1012

Threads: 73

Joined: Mar, 2021

Reputation: 37

Posted

henlo i made this like 6 months ago and just cleaned it up it's literally just axon animations but better and i added a couple more if you can't figure out how to use this then too bad

using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace Whatever;

public class Animator
{
        private readonly Storyboard _storyboard = new();

        private readonly IEasingFunction _smooth = new QuadraticEase
        {
            EasingMode = EasingMode.EaseInOut
        };
        
        public void FadeIn(DependencyObject @object, Duration duration)
        {
            var fadeIn = new DoubleAnimation()
            {
                From = 0.0,
                To = 1.0,
                Duration = duration
            };
            Storyboard.SetTarget(fadeIn, @object);
            Storyboard.SetTargetProperty(fadeIn, new PropertyPath("Opacity", 1));
            _storyboard.Children.Add(fadeIn);
            _storyboard.Begin();
            _storyboard.Children.Remove(fadeIn);
        }

        public void FadeOut(DependencyObject @object, Duration duration)
        {
            var fade = new DoubleAnimation()
            {
                From = 1.0,
                To = 0.0,
                Duration = duration
            };
            Storyboard.SetTarget(fade, @object);
            Storyboard.SetTargetProperty(fade, new PropertyPath("Opacity", 1));
            _storyboard.Children.Add(fade);
            _storyboard.Begin();
            _storyboard.Children.Remove(fade);
        }

        public void ObjectShift(DependencyObject @object, Thickness get, Thickness set, Duration duration)
        {
            var animation = new ThicknessAnimation()
            {
                From = get,
                To = set,
                Duration = duration,
                EasingFunction = _smooth,
            };
            Storyboard.SetTarget(animation, @object);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Margin"));
            _storyboard.Children.Add(animation);
            _storyboard.Begin();
            Task.Delay(1000);
            _storyboard.Children.Remove(animation);
        }

        public void WidthSlider(DependencyObject @object, double get, double set, Duration duration)
        {
            var animation = new DoubleAnimation
            {
                From = get,
                To = set,
                Duration = duration,
                EasingFunction = _smooth,
            };
            Storyboard.SetTarget(animation, @object);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Width"));
            _storyboard.Children.Add(animation);
            _storyboard.Begin();
            Task.Delay(500);
            _storyboard.Children.Remove(animation);
        }

        public void HeightSlider(DependencyObject @object, double get, double set, Duration duration)
        {
            var animation = new DoubleAnimation()
            {
                From = get,
                To = set,
                Duration = duration,
                EasingFunction = _smooth,
            };
            Storyboard.SetTarget(animation, @object);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Height"));
            _storyboard.Children.Add(animation);
            _storyboard.Begin();
            _storyboard.Children.Remove(animation);
        }

        public void ScaleY(ScaleTransform @object, double get, double set, Duration duration)
        {
            var animation = new DoubleAnimation()
            {
                From = get,
                To = set,
                Duration = duration,
                EasingFunction = _smooth,
            };
            @object.BeginAnimation(ScaleTransform.ScaleYProperty, animation, HandoffBehavior.SnapshotAndReplace);
        }

        public void ScaleX(ScaleTransform @object, double get, double set, Duration duration)
        {
            var animation = new DoubleAnimation()
            {
                From = get,
                To = set,
                Duration = duration,
                EasingFunction = _smooth,
            };
            @object.BeginAnimation(ScaleTransform.ScaleXProperty, animation, HandoffBehavior.SnapshotAndReplace);
        }
        
        public void ColorShift(DependencyObject @object, Color get, Color set, Duration duration)
        {
            var animation = new ColorAnimation()
            {
                From = get,
                To = set,
                Duration = duration,
                EasingFunction = _smooth,
            };
            Storyboard.SetTarget(animation, @object);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Color"));
            _storyboard.Children.Add(animation);
            _storyboard.Begin();
            Task.Delay(500);
            _storyboard.Children.Remove(animation);
        }

        public void Rotate(RotateTransform @object, double get, double set, Duration duration)
        {
            var animation = new DoubleAnimation()
            {
                From = get,
                To = set,
                Duration = duration,
                EasingFunction = _smooth,
            };
            @object.BeginAnimation(RotateTransform.AngleProperty, animation, HandoffBehavior.SnapshotAndReplace);
        }

}

  • 1

"Questionable intellegence, but I like the mystery" - CubeFaces

https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png

aeon

Owner of Voyager

vip

Posts: 262

Threads: 25

Joined: Sep, 2022

Reputation: 12

Replied

Ok this might be bad. But just in case I were to use it (not saying i will, not saying I wont.) is it compatable with winforms? (also im going with winforms cause thats my strong suit rn and its pretty easy compared to wpf, but im still gonna learn wpf, winforms images suck tho ngl) 

  • 0

SeizureSalad

i love femboys

Posts: 1012

Threads: 73

Joined: Mar, 2021

Reputation: 37

Replied

@aeon no this is for WPF I can make one for winforms if you really wanted

  • 1

"Questionable intellegence, but I like the mystery" - CubeFaces

https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png

aeon

Owner of Voyager

vip

Posts: 262

Threads: 25

Joined: Sep, 2022

Reputation: 12

Replied

@SeizureSalad If you wouldn't mind. Even if it's bad I'd at least like to test it to see if it fits with the style. If it does, I'll try to use it and give credits in the settings UI or credits UI if i make that.

  • 0

SeizureSalad

i love femboys

Posts: 1012

Threads: 73

Joined: Mar, 2021

Reputation: 37

Replied

@_realnickk NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO I AM NOT POO POO DEV I WROTE THIS IN LIKE 2021 WAWAAAGGHHHAEe

  • 0

"Questionable intellegence, but I like the mystery" - CubeFaces

https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png

Users viewing this thread:

( Members: 0, Guests: 0, Total: 0 )