public override Vector?GetValue(Keyframe <Vector?> keyframe, double keyframeProgress)
        {
            var pathKeyframe = (PathKeyframe)keyframe;
            var path         = pathKeyframe.Path;

            if (path == null || path.Contours.Count == 0)
            {
                return(keyframe.StartValue);
            }

            if (ValueCallback != null)
            {
                return(ValueCallback.GetValueInternal(pathKeyframe.StartFrame.Value, pathKeyframe.EndFrame.Value,
                                                      pathKeyframe.StartValue, pathKeyframe.EndValue, LinearCurrentKeyframeProgress,
                                                      keyframeProgress, Progress));
            }

            if (_pathMeasureKeyframe != pathKeyframe)
            {
                _pathMeasure?.Dispose();
                _pathMeasure         = new PathMeasure(path);
                _pathMeasureKeyframe = pathKeyframe;
            }

            return(_pathMeasure.GetPosTan(keyframeProgress * _pathMeasure.Length));
        }
Exemplo n.º 2
0
        protected internal override void ComputeRender(float renderProgress)
        {
            if (mCurrentBounds.IsEmpty)
            {
                return;
            }

            if (mMotherMovePath.IsEmpty)
            {
                mMotherMovePath.Set(CreateMotherMovePath());
                mMotherMovePathMeasure.SetPath(mMotherMovePath, false);

                mChildMovePath.Set(CreateChildMovePath());
                mChildMovePathMeasure.SetPath(mChildMovePath, false);
            }

            //mother oval
            float motherMoveProgress = MOTHER_MOVE_INTERPOLATOR.GetInterpolation(renderProgress);

            mMotherMovePathMeasure.GetPosTan(GetCurrentMotherMoveLength(motherMoveProgress), mMotherPosition, null);
            mMotherOvalHalfWidth  = mMaxMotherOvalSize;
            mMotherOvalHalfHeight = mMaxMotherOvalSize * GetMotherShapeFactor(motherMoveProgress);

            //child Oval
            float childMoveProgress = CHILD_MOVE_INTERPOLATOR.GetInterpolation(renderProgress);

            mChildMovePathMeasure.GetPosTan(GetCurrentChildMoveLength(childMoveProgress), mChildPosition, null);
            SetupChildParams(childMoveProgress);

            mRotateDegrees = (int)(DensityUtil.Radian2Degrees(Math.Atan((mMotherPosition[1] - mChildPosition[1]) / (mMotherPosition[0] - mChildPosition[0]))));

            mRevealCircleRadius     = GetCurrentRevealCircleRadius(renderProgress);
            mCurrentOvalColor       = GetCurrentOvalColor(renderProgress);
            mCurrentBackgroundColor = GetCurrentBackgroundColor(renderProgress);
        }
Exemplo n.º 3
0
                public override bool OnTouchEvent(MotionEvent e)
                {
                    var         touchX = e.GetX();
                    var         touchY = e.GetY();
                    PathMeasure pm     = new PathMeasure(DrawPath, false);

                    //coordinates will be here
                    float[] PrevCoords = { 0f, 0f };
                    //get coordinates of the middle point
                    pm.GetPosTan(pm.Length, PrevCoords, null);
                    switch (e.Action)
                    {
                    case MotionEventActions.Down:
                        DrawPath.MoveTo(touchX, touchY);
                        PointerDown = true;
                        try { Invalidate(); } catch (ObjectDisposedException) { return(false); }
                        PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs.
                                                                        PointerEventType.Down, new Point(PrevCoords[0], PrevCoords[1]),
                                                                        new Point(touchX, touchY), PointerDown));
                        break;

                    case MotionEventActions.Move:
                        DrawPath.LineTo(touchX, touchY);
                        try { Invalidate(); } catch (ObjectDisposedException) { return(false); }
                        PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs.
                                                                        PointerEventType.Move, new Point(PrevCoords[0], PrevCoords[1]),
                                                                        new Point(touchX, touchY), PointerDown));
                        break;

                    case MotionEventActions.Up:
                        DrawCanvas.DrawPath(DrawPath, DrawPaint);
                        DrawPath.Reset();
                        PointerDown = false;
                        try { Invalidate(); } catch (ObjectDisposedException) { return(false); }
                        PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs.
                                                                        PointerEventType.Up, new Point(PrevCoords[0], PrevCoords[1]),
                                                                        new Point(touchX, touchY), PointerDown));
                        break;

                    case MotionEventActions.Cancel:
                        DrawCanvas.DrawPath(DrawPath, DrawPaint);
                        DrawPath.Reset();
                        PointerDown = false;
                        try { Invalidate(); } catch (ObjectDisposedException) { return(false); }
                        PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs.
                                                                        PointerEventType.Cancel, new Point(PrevCoords[0], PrevCoords[1]),
                                                                        new Point(touchX, touchY), PointerDown));
                        break;

                    default:
                        return(false);
                    }

                    return(true);
                }
Exemplo n.º 4
0
 /**
  * Returns a point on this curve at the given {@code parameter}.
  * For {@code parameter} values less than .5f, the first path will drive the point.
  * For {@code parameter} values greater than .5f, the second path will drive the point.
  * For {@code parameter} equal to .5f, the point will be the point where the two
  * internal paths connect.
  */
 public void getPointOnLine(float parameter, float[] coords)
 {
     if (parameter <= .5f)
     {
         parameter *= 2;
         measureFirst.GetPosTan(lengthFirst * parameter, coords, null);
     }
     else
     {
         parameter -= .5f;
         parameter *= 2;
         measureSecond.GetPosTan(lengthSecond * parameter, coords, null);
     }
 }
Exemplo n.º 5
0
        public override Vector2?GetValue(Keyframe <Vector2?> keyframe, float keyframeProgress)
        {
            var pathKeyframe = (PathKeyframe)keyframe;
            var path         = pathKeyframe.Path;

            if (path == null || path.Contours.Count == 0)
            {
                return(keyframe.StartValue);
            }

            if (_pathMeasureKeyframe != pathKeyframe)
            {
                _pathMeasure         = new PathMeasure(path);
                _pathMeasureKeyframe = pathKeyframe;
            }

            return(_pathMeasure.GetPosTan(keyframeProgress * _pathMeasure.Length));
        }
        // Used to fetch points from given path.
        private PathPoints[] getPoints(Path p)
        {
            //Size of 1000 indicates that, 1000 points
            // would be extracted from the path
            var pointArray   = new PathPoints[1000];
            var pm           = new PathMeasure(p, false);
            var length       = pm.Length;
            var distance     = 0f;
            var speed        = length / 1000;
            var counter      = 0;
            var aCoordinates = new float[2];

            while ((distance < length) && (counter < 1000))
            {
                pm.GetPosTan(distance, aCoordinates, null);
                pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
                counter++;
                distance = distance + speed;
            }

            return(pointArray);
        }
        private PathPoints[] getPoints(Path path)
        {
            PathPoints[] pointArray = new PathPoints[100];
            PathMeasure  pm         = new PathMeasure(path, false);
            float        length     = pm.Length;
            float        distance   = 0f;
            float        speed      = length / 100;
            int          counter    = 0;

            float[] aCoordinates = new float[2];

            while ((distance < length) && (counter < 100))
            {
                // get point from the pathMoon
                pm.GetPosTan(distance, aCoordinates, null);
                pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
                counter++;
                distance = distance + speed;
            }

            return(pointArray);
        }