Exemplo n.º 1
0
        public PathF Rotate(float angle, PointF pivotPoint)
        {
            var path = new PathF();

            var index          = 0;
            var arcIndex       = 0;
            var clockwiseIndex = 0;

            foreach (var operation in _operations)
            {
                if (operation == PathOperation.MoveTo)
                {
                    var point = GetRotatedPoint(index++, pivotPoint, angle);
                    path.MoveTo(point);
                }
                else if (operation == PathOperation.Line)
                {
                    var point = GetRotatedPoint(index++, pivotPoint, angle);
                    path.LineTo(point.X, point.Y);
                }
                else if (operation == PathOperation.Quad)
                {
                    var controlPoint = GetRotatedPoint(index++, pivotPoint, angle);
                    var point        = GetRotatedPoint(index++, pivotPoint, angle);
                    path.QuadTo(controlPoint.X, controlPoint.Y, point.X, point.Y);
                }
                else if (operation == PathOperation.Cubic)
                {
                    var controlPoint1 = GetRotatedPoint(index++, pivotPoint, angle);
                    var controlPoint2 = GetRotatedPoint(index++, pivotPoint, angle);
                    var point         = GetRotatedPoint(index++, pivotPoint, angle);
                    path.CurveTo(controlPoint1.X, controlPoint1.Y, controlPoint2.X, controlPoint2.Y, point.X, point.Y);
                }
                else if (operation == PathOperation.Arc)
                {
                    var topLeft     = GetRotatedPoint(index++, pivotPoint, angle);
                    var bottomRight = GetRotatedPoint(index++, pivotPoint, angle);
                    var startAngle  = _arcAngles[arcIndex++];
                    var endAngle    = _arcAngles[arcIndex++];
                    var clockwise   = _arcClockwise[clockwiseIndex++];

                    path.AddArc(topLeft, bottomRight, startAngle, endAngle, clockwise);
                }
                else if (operation == PathOperation.Close)
                {
                    path.Close();
                }
            }

            return(path);
        }
Exemplo n.º 2
0
        private void LineTo(bool isRelative)
        {
            var point = NewPoint(NextValue, NextValue, isRelative, true);

            _path.LineTo(point);
        }