コード例 #1
0
        public CVImage Smooth(SmoothType smoothtype, int param1, int param2, double param3, double param4)
        {
            CVImage dst = this.Clone();

            PInvoke.cvSmooth(new __CvArrPtr(this), new __CvArrPtr(dst), (int)smoothtype, param1, param2, param3, param4);
            return(dst);
        }
コード例 #2
0
    // takes 't' and smoothes it.
    public static float Smooth0to1(this float t, SmoothType smoothType)
    {
        t = Mathf.Clamp01(t);

        switch (smoothType)
        {
        case SmoothType.none:
            break;

        case SmoothType.smoothstep:
            t = t * t * (3f - 2f * t);
            break;

        case SmoothType.smootherstep:
            t = t * t * t * (t * (6f * t - 15f) + 10f);
            break;

        case SmoothType.exponential:
            t = t * t;
            break;

        case SmoothType.easeIn:
            t = 1f - Mathf.Cos(t * Mathf.PI * 0.5f);
            break;

        case SmoothType.easeOut:
            t = Mathf.Sin(t * Mathf.PI * 0.5f);
            break;
        }

        return(t);
    }
コード例 #3
0
ファイル: Tween.cs プロジェクト: masterchop/Particles
 /// <summary>
 /// Specifies that this Tween should the given smoothing method.
 /// </summary>
 public Tween Smooth(SmoothType type = SmoothType.Smooth)
 {
     throwIfInvalid();
     _instance.smoothType     = type;
     _instance.smoothFunction = null;
     return(this);
 }
コード例 #4
0
 private void BlendToTransform(float pSmoothTime, SmoothType pSmoothType)
 {
     StopAllCoroutines();
     if (_orhto)
     {
         StartCoroutine(SmoothFromTo(_cam.transform.position, _orthoPosition, _cam.transform.rotation.eulerAngles, _orthoRotation, pSmoothTime, pSmoothType));
     }
     else
     {
         StartCoroutine(SmoothFromTo(_cam.transform.position, _perspPosition, _cam.transform.rotation.eulerAngles, _perpRotation, pSmoothTime, pSmoothType));
     }
 }
コード例 #5
0
 public void SwitchMatrix(float pSmoothTime, SmoothType pSmoothType)
 {
     _ortho = !_ortho;
     if (_ortho)
     {
         BlendToMatrix(_matrixOrtho, pSmoothTime, pSmoothType);
     }
     else
     {
         BlendToMatrix(_matrixPersp, pSmoothTime, pSmoothType);
     }
 }
コード例 #6
0
        public void ResetDefaults()
        {
            returnToPoolUponStop = true;

            curPercent = 0;
            dstPercent = 1;
            velPercent = 1; //By default, tween over the course of 1 second
            direction  = Direction.Forward;

            smoothType     = SmoothType.Linear;
            smoothFunction = null;

            OnProgress   = null;
            OnLeaveEnd   = null;
            OnReachEnd   = null;
            OnLeaveStart = null;
            OnReachStart = null;
        }
コード例 #7
0
        public Bitmap Smooth(SmoothType st)
        {
            Bitmap ret = new Bitmap(1, 1);

            switch (st)
            {
            case SmoothType.MEAN_SMOOTH:
                ret = meanSmooth();
                break;

            case SmoothType.MEDIAN_SMOOTH:
                ret = medianSmooth();
                break;

            case SmoothType.GAUSSIAN_SMOOTH:
                ret = gaussianSmooth();
                break;
            }

            return(ret);
        }
コード例 #8
0
        public static float Interpolation(this float t, SmoothType type)
        {
            switch (type)
            {
            case SmoothType.SmootherStep:
                return(t * t * (3 - 2 * t));

            case SmoothType.SoSmootherStep:
                return(t * t * t * (t * (6f * t - 15f) + 10f));

            case SmoothType.EaseOutWithSin:
                return(Mathf.Sin(t * Mathf.PI * 0.5f));

            case SmoothType.EaseInWithCos:
                return(1f - Mathf.Cos(t * Mathf.PI * 0.5f));

            case SmoothType.Exponential:
                return(t * t);

            default:
                return(t);
            }
        }
コード例 #9
0
 public CVImage Smooth(SmoothType smoothtype)
 {
     return(Smooth(smoothtype, 3));
 }
コード例 #10
0
ファイル: CvInvoke.cs プロジェクト: sanglin307/UnityOpenCV
 public static extern void cvSmooth(IntPtr src, IntPtr dst, SmoothType type, int param1, int param2, double param3, double param4);
コード例 #11
0
 public CVImage Smooth(SmoothType smoothtype, int param1, int param2)
 {
     return Smooth(smoothtype, param1, param2, 0);
 }
コード例 #12
0
 public CVImage Smooth(SmoothType smoothtype, int param1, int param2, double param3)
 {
     return Smooth(smoothtype, param1, param2, param3, 0);
 }
コード例 #13
0
        public override void KeyPressed(KeyConstant key, Scancode scancode, bool isRepeat)
        {
            base.KeyPressed(key, scancode, isRepeat);

            switch (key)
            {
            case KeyConstant.Right:
                horizontal_smoothness++;
                break;

            case KeyConstant.Left:
                if (horizontal_smoothness > 1)
                {
                    horizontal_smoothness--;
                }
                break;

            case KeyConstant.Down:
                if (vertical_smoothness > 1)
                {
                    vertical_smoothness--;
                    for (int i = 0; i < smooth.Count; i++)
                    {
                        smooth.RemoveAt(i);
                    }
                }
                break;

            case KeyConstant.Up:
                vertical_smoothness++;
                for (int i = 0; i < smooth.Count; i++)
                {
                    smooth.RemoveAt(i);
                }
                break;

            case KeyConstant.H:
                smoothType = SmoothType.horizontal;
                break;

            case KeyConstant.V:
                smoothType = SmoothType.vertical;
                break;

            case KeyConstant.B:
                smoothType = SmoothType.both;
                break;

            case KeyConstant.Number1:
                vis_mode = 0;
                break;

            case KeyConstant.Number2:
                vis_mode = 1;
                break;

            case KeyConstant.Number3:
                vis_mode = 2;
                break;

            case KeyConstant.Number4:
                vis_mode = 3;
                break;

            case KeyConstant.Number5:
                vis_mode = 4;
                break;

            case KeyConstant.Number6:
                vis_mode = 5;
                break;

            case KeyConstant.Number7:
                vis_mode = 6;
                break;

            case KeyConstant.Number8:
                vis_mode = 7;
                break;

            case KeyConstant.Number9:
                vis_mode = 8;
                break;

            case KeyConstant.Number0:
                vis_mode = 9;
                break;
            }
        }
コード例 #14
0
 public CVImage Smooth(SmoothType smoothtype, int param1, int param2, double param3)
 {
     return(Smooth(smoothtype, param1, param2, param3, 0));
 }
コード例 #15
0
 public CVImage Smooth(SmoothType smoothtype, int param1, int param2, double param3, double param4)
 {
     CVImage dst = this.Clone();
     PInvoke.cvSmooth(new __CvArrPtr(this), new __CvArrPtr(dst), (int)smoothtype, param1, param2, param3, param4);
     CVUtils.CheckLastError();
     return dst;
 }
コード例 #16
0
 public CVImage Smooth(SmoothType smoothtype, int param1, int param2)
 {
     return(Smooth(smoothtype, param1, param2, 0));
 }
コード例 #17
0
 public CVImage Smooth(SmoothType smoothtype)
 {
     return Smooth(smoothtype, 3);
 }
コード例 #18
0
 IEnumerator SmoothFromTo(Vector3 pPositionStart, Vector3 pPositionEnd, Vector2 pRotationStart, Vector2 pRotationEnd, float pSmoothTime, SmoothType pSmoothType)
 {
     for (float t = 0; t <= pSmoothTime; t += Time.deltaTime)
     {
         if (pSmoothType == SmoothType.Lerp)
         {
             _cam.transform.position = Vector3.Lerp(pPositionStart, pPositionEnd, t / pSmoothTime);
             _cam.transform.rotation = Quaternion.Euler(Vector3.Lerp(pRotationStart, pRotationEnd, t / pSmoothTime));
         }
         else if (pSmoothType == SmoothType.SmoothStep)
         {
             _cam.transform.position = SmoothStepV3(pPositionStart, pPositionEnd, t / pSmoothTime);
             _cam.transform.rotation = Quaternion.Euler(SmoothStepV3(pRotationStart, pRotationEnd, t / pSmoothTime));
         }
         else if (pSmoothType == SmoothType.SmootherStep)
         {
             _cam.transform.position = SmoothertStepV3(pPositionStart, pPositionEnd, t / pSmoothTime);
             _cam.transform.rotation = Quaternion.Euler(SmoothertStepV3(pRotationStart, pRotationEnd, t / pSmoothTime));
         }
         else if (pSmoothType == SmoothType.SmoothestStep)
         {
             _cam.transform.position = SmoothestStepV3(pPositionStart, pPositionEnd, t / pSmoothTime);
             _cam.transform.rotation = Quaternion.Euler(SmoothestStepV3(pRotationStart, pRotationEnd, t / pSmoothTime));
         }
         yield return(new WaitForEndOfFrame());;
     }
 }
コード例 #19
0
 private void BlendToMatrix(Matrix4x4 pDst, float pSmoothTime, SmoothType pSmoothType)
 {
     StopAllCoroutines();
     StartCoroutine(SmoothFromTo(_cam.projectionMatrix, pDst, pSmoothTime, pSmoothType));
 }
コード例 #20
0
    private IEnumerator SmoothFromTo(Matrix4x4 pSrc, Matrix4x4 pDst, float pSmoothTime, SmoothType pSmoothType)
    {
        for (float t = 0; t <= pSmoothTime; t += Time.deltaTime)
        {
            if (pSmoothType == SmoothType.Lerp)
            {
                _cam.projectionMatrix = LerpMatrix(pSrc, pDst, t / pSmoothTime);
            }
            else if (pSmoothType == SmoothType.SmoothStep)
            {
                _cam.projectionMatrix = SmoothStepMatrix(pSrc, pDst, t / pSmoothTime);
            }
            else if (pSmoothType == SmoothType.SmootherStep)
            {
                _cam.projectionMatrix = SmootherStepMatrix(pSrc, pDst, t / pSmoothTime);
            }
            else if (pSmoothType == SmoothType.SmoothestStep)
            {
                _cam.projectionMatrix = SmoothestStepMatrix(pSrc, pDst, t / pSmoothTime);
            }
            yield return(new WaitForEndOfFrame());;
        }

        _cam.projectionMatrix = pDst;
    }