Ejemplo n.º 1
0
        private void Arc(VectorCommand instruction, bool isRelative)
        {
            for (int i = 0; i < instruction.Arguments.Length; i = i + 6)
            {
                float w              = instruction.Arguments[0];
                float h              = instruction.Arguments[1];
                float a              = instruction.Arguments[2];
                bool  isLargeArc     = (int)instruction.Arguments[3] == 1;
                bool  sweepDirection = (int)instruction.Arguments[4] == 1;

                var p = new Vector2(instruction.Arguments[5], instruction.Arguments[6]);
                if (isRelative)
                {
                    p += _previousPoint;
                }

                var arcSegment = new ArcSegment
                {
                    ArcSize        = isLargeArc ? ArcSize.Large : ArcSize.Small,
                    RotationAngle  = a,
                    SweepDirection = sweepDirection ? SweepDirection.Clockwise : SweepDirection.CounterClockwise,
                    Point          = p,
                    Size           = new Size2F(w, h)
                };
                _sink.AddArc(arcSegment);
            }
        }
Ejemplo n.º 2
0
        private void VerticalLine(VectorCommand instruction, bool isRelative)
        {
            var points = new List <Vector2>();

            for (var i = 0; i < instruction.Arguments.Length; i++)
            {
                var point = new Vector2(_previousPoint.X, instruction.Arguments[i]);
                if (isRelative)
                {
                    point += new Vector2(0, _previousPoint.Y);
                }
                points.Add(point);
                _previousPoint = points[i];
            }
            _sink.AddLines(points.ToRawVector2().ToArray());
        }
Ejemplo n.º 3
0
        private void Line(VectorCommand instruction, bool isRelative)
        {
            var points = new List <Vector2>();

            for (var i = 0; i < instruction.Arguments.Length; i = i + 2)
            {
                var point = new Vector2(instruction.Arguments[i], instruction.Arguments[i + 1]);
                if (isRelative)
                {
                    point += _previousPoint;
                }
                points.Add(point);
                _previousPoint = points[i];
            }
            _sink.AddLines(points.ToRawVector2().ToArray());
        }
Ejemplo n.º 4
0
        private void Move(VectorCommand instruction, bool isRelative)
        {
            if (IsFigureOpen)
            {
                Close(FigureEnd.Open);
            }

            var point = new Vector2(instruction.Arguments[0], instruction.Arguments[1]);

            if (isRelative)
            {
                point += _startPoint;
            }
            _startPoint    = isRelative ? point + _startPoint : point;
            _previousPoint = _startPoint;
            _sink.BeginFigure(_startPoint, FigureBegin.Filled);
            IsFigureOpen = true;
        }
Ejemplo n.º 5
0
        private void CubicBezierCurve(VectorCommand instruction, bool isRelative)
        {
            for (int i = 0; i < instruction.Arguments.Length; i = i + 6)
            {
                var p1 = new Vector2(instruction.Arguments[0], instruction.Arguments[1]);
                var p2 = new Vector2(instruction.Arguments[2], instruction.Arguments[3]);
                var p3 = new Vector2(instruction.Arguments[4], instruction.Arguments[5]);
                if (isRelative)
                {
                    p1 += _previousPoint;
                    p2 += _previousPoint;
                    p3 += _previousPoint;
                }

                var bezSegment = new BezierSegment()
                {
                    Point1 = p1,
                    Point2 = p2,
                    Point3 = p3
                };

                _sink.AddBezier(bezSegment);
            }
        }