Esempio n. 1
0
        private void Touch_move(float x, float y)
        {
            float dx = Math.Abs(x - mX);
            float dy = Math.Abs(y - mY);

            if (!(dx >= TouchTolerance) && !(dy >= TouchTolerance))
            {
                return;
            }

            mPath.QuadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
            mX = x;
            mY = y;
        }
Esempio n. 2
0
        protected override void OnDraw(Canvas canvas)
        {
            var trans = Element.RenderTransform ?? new IdentityTransform();

            var path = new global::Android.Graphics.Path();

            foreach (var command in PathDataParser.ToAbsolute(PathDataParser.Parse(Element.Data)))
            {
                switch (command.Type)
                {
                case PathDataParser.CommandType.MoveTo:
                {
                    var pt = trans.TransformPoint(
                        new System.Drawing.PointF(command.Arguments[0], command.Arguments[1]));
                    path.MoveTo(pt.X, pt.Y);
                }
                break;

                case PathDataParser.CommandType.LineTo:
                {
                    var pt = trans.TransformPoint(
                        new System.Drawing.PointF(command.Arguments[0], command.Arguments[1]));
                    path.LineTo(pt.X, pt.Y);
                }
                break;

                case PathDataParser.CommandType.QBezier:
                {
                    var pt = trans.TransformPoint(
                        new System.Drawing.PointF(command.Arguments[0], command.Arguments[1]));
                    var pt2 = trans.TransformPoint(
                        new System.Drawing.PointF(command.Arguments[2], command.Arguments[3]));

                    path.QuadTo(pt.X, pt.Y, pt2.X, pt2.Y);
                }

                break;

                case PathDataParser.CommandType.Bezier:
                {
                    var pt = trans.TransformPoint(
                        new System.Drawing.PointF(command.Arguments[0], command.Arguments[1]));
                    var pt2 = trans.TransformPoint(
                        new System.Drawing.PointF(command.Arguments[2], command.Arguments[3]));
                    var pt3 = trans.TransformPoint(
                        new System.Drawing.PointF(command.Arguments[4], command.Arguments[5]));

                    path.CubicTo(pt.X, pt.Y, pt2.X, pt2.Y, pt3.X, pt3.Y);
                }
                break;

                case PathDataParser.CommandType.Close:
                    path.Close();
                    DrawPath(canvas, path);
                    path = new global::Android.Graphics.Path();
                    break;
                }
            }

            if (!path.IsEmpty)
            {
                DrawPath(canvas, path);
            }
        }