Ejemplo n.º 1
0
        protected override async Task Act(ActParameters Parameters)
        {
            bool Success = true;
            var  context = InitializeContext(Parameters, ref Success);

            if (!Success)
            {
                Debug.LogWarning("Animation initialization failed.", this);
                return;
            }

            var target = ConvertData(Target);

            if (Duration <= 0)
            {
                Set(ref context, target);
                return;
            }
            float Speed = 1 / Duration;

            var start = EvaluateStartPoint(ref context);

            for (float t = 0; t < 1; t += Time.deltaTime * Speed)
            {
                Set(ref context, Lerp(
                        start,
                        target,
                        Interpolators.Interpolate(InterpolationType, t)
                        ));
                await Parameters.Yield();
            }
            Set(ref context, target);
        }
Ejemplo n.º 2
0
 private bool ensureInterpolator()
 {
     if (this.Interpolator == null)
     {
         this.Interpolator = Interpolators.Get <T>();
     }
     return(this.Interpolator != null);
 }
Ejemplo n.º 3
0
 protected void OnDestroy()
 {
     this._destroying = true;
     if (this._running)
     {
         Interpolators.SetDisabled(this);
         this._running = false;
     }
 }
Ejemplo n.º 4
0
        public PricingResults Results(OptionInstrument option, PricingConfiguration pricingcfg)
        {
            var    blackModel   = new BlackModelOption();
            double riskfacor    = Interpolators.InterpolateForward(option.SousJacent, option.RiskFactorDate);
            double price        = blackModel.PriceBlackModel(option, riskfacor);
            var    resultGreeks = blackModel.ComputeGreeks(pricingcfg.GreeksToCompute, riskfacor, option);

            return(new PricingResults(resultGreeks, price));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Performs a linear interpolation between the specified values.
        /// </summary>
        /// <typeparam name="T">The type of value to tween.</typeparam>
        /// <param name="lerpStart">The start value.</param>
        /// <param name="lerpEnd">The end value.</param>
        /// <param name="t">A value between 0.0 and 1.0 indicating the current position in the interpolation.</param>
        /// <returns>A value which is interpolated from the specified start and end values.</returns>
        public static T LerpRef <T>(ref T lerpStart, ref T lerpEnd, Single t) where T : struct
        {
            Interpolator <T> interpolator;

            if (!Interpolators.TryGet <T>(out interpolator) || interpolator == null)
            {
                return((T)Tween(lerpStart, (Object)lerpEnd, Easings.EaseInLinear, t));
            }
            return(interpolator(lerpStart, lerpEnd, Easings.EaseInLinear, t));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Tweens the specified values.
        /// </summary>
        /// <typeparam name="T">The type of value to tween.</typeparam>
        /// <param name="tweenStart">The start value.</param>
        /// <param name="tweenEnd">The end value.</param>
        /// <param name="fn">The easing function to apply.</param>
        /// <param name="t">A value between 0.0 and 1.0 indicating the current position in the tween.</param>
        /// <returns>A value which is interpolated from the specified start and end values.</returns>
        public static T TweenRef <T>(ref T tweenStart, ref T tweenEnd, EasingFunction fn, Single t) where T : struct
        {
            Interpolator <T> interpolator;

            if (!Interpolators.TryGet <T>(out interpolator) || interpolator == null)
            {
                return((T)Tween(tweenStart, (Object)tweenEnd, fn, t));
            }
            return(interpolator(tweenStart, tweenEnd, fn, t));
        }
Ejemplo n.º 7
0
    private void OnDrawGizmos()
    {
        int numSamples = 10;

        for (int i = 0; i < numSamples; i++)
        {
            float ratio = Interpolators.bounceInOut(0, 1, (float)i / (float)numSamples);

            Gizmos.DrawWireSphere(Vector3.Lerp(startingPoint,
                                               transformations[0].position, ratio), 0.1f);
        }
    }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        float ratio = Interpolators.expoOut(0, 1, t);


        transform.position = Vector3.Lerp(startingPoint,
                                          transformations[actualId].position, ratio);


        t += Time.deltaTime;
        if (t >= 1.0f)
        {
            actualId++;
            actualId %= transformations.Length;
            t         = 0.0f;
        }
    }
Ejemplo n.º 9
0
        public ImageProcessor(System.Drawing.Bitmap bitmap, double width, double height, double lineRes, double pointRes, double angle, Interpolators.IInterpolator interpolator)
        {
            if (width < 0)
                throw new Exception("Width can not be negative");
            if (height < 0)
                throw new Exception("Height can not be negative");
            if (lineRes < 0)
                throw new Exception("lineRes can not be negative");
            if (pointRes < 0)
                throw new Exception("pointRes can not be negative");

            _Angle = angle;
            _PointRes = pointRes;
            _LineRes = lineRes;
            _Height = height;
            _Width = width;
            _image = new Image(width, height, bitmap, interpolator);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes the <see cref="Tweening"/> type.
        /// </summary>
        static Tweening()
        {
            Interpolators.Register <Object>(Tween);
            Interpolators.Register <Boolean>(Tween);
            Interpolators.Register <Byte>(Tween);
            Interpolators.Register <SByte>(Tween);
            Interpolators.Register <Char>(Tween);
            Interpolators.Register <Int16>(Tween);
            Interpolators.Register <Int32>(Tween);
            Interpolators.Register <Int64>(Tween);
            Interpolators.Register <UInt16>(Tween);
            Interpolators.Register <UInt32>(Tween);
            Interpolators.Register <UInt64>(Tween);
            Interpolators.Register <Single>(Tween);
            Interpolators.Register <Double>(Tween);
            Interpolators.Register <Decimal>(Tween);

            Interpolators.RegisterDefault <Color>();
        }
Ejemplo n.º 11
0
        //public Image(int width, int height)
        //{
        //    _pixels = new Pixel[width, height];
        //    for (int x = 0; x < width; x++)
        //        for (int y = 0; y < height; y++)
        //            _pixels[x, y] = new Pixel(x, y);
        //}
        public Image(double width, double height, System.Drawing.Bitmap bitmap, Interpolators.IInterpolator interpolator)
        {
            if (interpolator == null)
                throw new ArgumentNullException("interpolator", "interpolator is null.");
            if (bitmap == null)
                throw new ArgumentNullException("bitmap", "bitmap is null.");
            if (Width < 0)
                throw new Exception("Width can't be negative");
            if (Height < 0)
                throw new Exception("Height can't be negative");

            Width = width;
            Height = height;
            _interpolator = interpolator;

            ScaleHorizontal = (bitmap.Width - 1) / Width;
            ScaleVertical = (bitmap.Height - 1) / Height;

            _pixels = new Pixel[bitmap.Width, bitmap.Height];

            for (int x = 0; x < bitmap.Width; x++)
                for (int y = 0; y < bitmap.Height; y++)
                    _pixels[x, y] = new Pixel(bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness(), x, y);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// <para>Returns a Tween&lt;T&gt; object that is configured to animate the named property of the target object.</para>
 /// <b>For example, to tween the "timeScale" property of a custom class, you could use the following:</b><pre><code>
 /// var tween = TweenProperty&lt;float&gt;
 ///		.Obtain( target, "timeScale" )
 ///		.SetStartValue( 0f )
 ///		.SetEndValue( 1f )
 ///		.SetDuration( 0.5f );
 /// </code></pre>
 /// </summary>
 /// <param name="target">The object to be animated</param>
 /// <param name="propertyName">The name of the property to be animated</param>
 public static Tween <T> Obtain(object target, string propertyName)
 {
     return(Obtain(target, propertyName, Interpolators.Get <T>()));
 }
Ejemplo n.º 13
0
 internal static void SyncronizeAll()
 {
     Interpolators.UpdateAll();
 }