Exemplo n.º 1
0
        private void AddSmoothCubicBezierCurve(CommandToken commandToken)
        {
            var point2 = commandToken.IsRelative
                             ? commandToken.ReadRelativePoint(_currentPoint)
                             : commandToken.ReadPoint();

            var end = commandToken.IsRelative
                          ? commandToken.ReadRelativePoint(_currentPoint)
                          : commandToken.ReadPoint();

            if (_previousControlPoint != null)
            {
                _previousControlPoint = MirrorControlPoint((Point)_previousControlPoint, _currentPoint);
            }

            if (_isOpen == null)
            {
                CreateFigure();
            }

            _geometryContext.CubicBezierTo(_previousControlPoint ?? _currentPoint, point2, end);

            _previousControlPoint = point2;

            _currentPoint = end;
        }
Exemplo n.º 2
0
        private void AddCubicBezierCurve(CommandToken commandToken)
        {
            var point1 = commandToken.IsRelative
                             ? commandToken.ReadRelativePoint(_currentPoint)
                             : commandToken.ReadPoint();

            var point2 = commandToken.IsRelative
                             ? commandToken.ReadRelativePoint(_currentPoint)
                             : commandToken.ReadPoint();

            _previousControlPoint = point2;

            var point3 = commandToken.IsRelative
                             ? commandToken.ReadRelativePoint(_currentPoint)
                             : commandToken.ReadPoint();

            if (_isOpen == null)
            {
                CreateFigure();
            }

            _geometryContext.CubicBezierTo(point1, point2, point3);

            _currentPoint = point3;
        }
Exemplo n.º 3
0
        private void AddArc(CommandToken commandToken)
        {
            var size = commandToken.ReadSize();

            var rotationAngle = commandToken.ReadDouble();

            var isLargeArc = commandToken.ReadBool();

            var sweepDirection = commandToken.ReadBool() ? SweepDirection.Clockwise : SweepDirection.CounterClockwise;

            var end = commandToken.IsRelative
                          ? commandToken.ReadRelativePoint(_currentPoint)
                          : commandToken.ReadPoint();

            if (_isOpen == null)
            {
                CreateFigure();
            }

            _geometryContext.ArcTo(end, size, rotationAngle, isLargeArc, sweepDirection);

            _currentPoint = end;

            _previousControlPoint = null;
        }
Exemplo n.º 4
0
        private void AddMove(CommandToken commandToken)
        {
            var currentPoint = commandToken.IsRelative
                                   ? commandToken.ReadRelativePoint(_currentPoint)
                                   : commandToken.ReadPoint();

            _currentPoint = currentPoint;

            CreateFigure();

            if (!commandToken.HasImplicitCommands)
            {
                return;
            }

            while (commandToken.HasImplicitCommands)
            {
                AddLine(commandToken);

                if (commandToken.IsRelative)
                {
                    continue;
                }

                _currentPoint = currentPoint;

                CreateFigure();
            }
        }
Exemplo n.º 5
0
        private void AddQuadraticBezierCurve(CommandToken commandToken)
        {
            var start = commandToken.IsRelative
                            ? commandToken.ReadRelativePoint(_currentPoint)
                            : commandToken.ReadPoint();

            _previousControlPoint = start;

            var end = commandToken.IsRelative
                          ? commandToken.ReadRelativePoint(_currentPoint)
                          : commandToken.ReadPoint();

            if (_isOpen == null)
            {
                CreateFigure();
            }

            _geometryContext.QuadraticBezierTo(start, end);

            _currentPoint = end;
        }
Exemplo n.º 6
0
        private void AddLine(CommandToken commandToken)
        {
            _currentPoint = commandToken.IsRelative
                                ? commandToken.ReadRelativePoint(_currentPoint)
                                : commandToken.ReadPoint();

            if (_isOpen == null)
            {
                CreateFigure();
            }

            _geometryContext.LineTo(_currentPoint);
        }