コード例 #1
0
ファイル: PathBuilder.cs プロジェクト: twsouthwick/Comet
        private void SmoothCurveTo(bool isRelative)
        {
            var point1 = new PointF();
            var point2 = NewPoint(NextValue, NextValue, isRelative, false);

            // ReSharper disable ConvertIfStatementToNullCoalescingExpression
            if (_relativePoint != null)
            {
                if (_lastCurveControlPoint == null)
                {
                    // ReSharper restore ConvertIfStatementToNullCoalescingExpression
                    point1 = GraphicsOperations.GetOppositePoint((PointF)_relativePoint, point2);
                }
                else if (_relativePoint != null)
                {
                    point1 = GraphicsOperations.GetOppositePoint((PointF)_relativePoint, (PointF)_lastCurveControlPoint);
                }
            }

            var point3 = NewPoint(NextValue, NextValue, isRelative, true);

            _path.CurveTo(point1, point2, point3);
            _lastCurveControlPoint = point2;
        }
コード例 #2
0
ファイル: PathF.cs プロジェクト: AndreAbrantes/Comet
        private PointF GetRotatedPoint(int index, PointF center, float angleInDegrees)
        {
            var point = _points[index];

            return(GraphicsOperations.RotatePoint(center, point, angleInDegrees));
        }
コード例 #3
0
ファイル: PathF.cs プロジェクト: AndreAbrantes/Comet
        private RectangleF CalculateBounds()
        {
            var xValues = new List <float>();
            var yValues = new List <float>();

            int pointIndex        = 0;
            int arcAngleIndex     = 0;
            int arcClockwiseIndex = 0;

            foreach (var operation in PathOperations)
            {
                if (operation == PathOperation.MoveTo)
                {
                    pointIndex++;
                }
                else if (operation == PathOperation.Line)
                {
                    var startPoint = _points[pointIndex - 1];
                    var endPoint   = _points[pointIndex++];

                    xValues.Add(startPoint.X);
                    xValues.Add(endPoint.X);
                    yValues.Add(startPoint.Y);
                    yValues.Add(endPoint.Y);
                }
                else if (operation == PathOperation.Quad)
                {
                    var startPoint   = _points[pointIndex - 1];
                    var controlPoint = _points[pointIndex++];
                    var endPoint     = _points[pointIndex++];

                    var bounds = GraphicsOperations.GetBoundsOfQuadraticCurve(startPoint, controlPoint, endPoint);

                    xValues.Add(bounds.Left);
                    xValues.Add(bounds.Right);
                    yValues.Add(bounds.Top);
                    yValues.Add(bounds.Bottom);
                }
                else if (operation == PathOperation.Cubic)
                {
                    var startPoint    = _points[pointIndex - 1];
                    var controlPoint1 = _points[pointIndex++];
                    var controlPoint2 = _points[pointIndex++];
                    var endPoint      = _points[pointIndex++];

                    var bounds = GraphicsOperations.GetBoundsOfCubicCurve(startPoint, controlPoint1, controlPoint2, endPoint);

                    xValues.Add(bounds.Left);
                    xValues.Add(bounds.Right);
                    yValues.Add(bounds.Top);
                    yValues.Add(bounds.Bottom);
                }
                else if (operation == PathOperation.Arc)
                {
                    var   topLeft     = _points[pointIndex++];
                    var   bottomRight = _points[pointIndex++];
                    float startAngle  = GetArcAngle(arcAngleIndex++);
                    float endAngle    = GetArcAngle(arcAngleIndex++);
                    var   clockwise   = IsArcClockwise(arcClockwiseIndex++);

                    var bounds = GraphicsOperations.GetBoundsOfArc(topLeft.X, topLeft.Y, bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y, startAngle, endAngle, clockwise);

                    xValues.Add(bounds.Left);
                    xValues.Add(bounds.Right);
                    yValues.Add(bounds.Top);
                    yValues.Add(bounds.Bottom);
                }
            }

            var minX = xValues.Min();
            var minY = yValues.Min();
            var maxX = xValues.Max();
            var maxY = yValues.Max();

            return(new RectangleF(minX, minY, maxX - minX, maxY - minY));
        }
コード例 #4
0
 public void RotateInDegrees(float angleInDegrees, float px, float py)
 {
     Rotate(GraphicsOperations.DegreesToRadians(angleInDegrees), px, py);
 }
コード例 #5
0
 public void RotateInDegrees(float angleInDegrees)
 {
     Rotate(GraphicsOperations.DegreesToRadians(angleInDegrees));
 }