Exemplo n.º 1
0
        private Ellipse CreateEllipticalArc(Core2D.Shapes.XArc arc, double dx, double dy)
        {
            var a = Core2D.Math.Arc.GdiArc.FromXArc(arc, dx, dy);

            double _cx        = ToDxfX(a.X + a.Width / 2.0);
            double _cy        = ToDxfY(a.Y + a.Height / 2.0);
            double minor      = Math.Min(a.Height, a.Width);
            double major      = Math.Max(a.Height, a.Width);
            double startAngle = -a.EndAngle;
            double endAngle   = -a.StartAngle;
            double rotation   = 0;

            if (a.Height > a.Width)
            {
                startAngle += 90;
                endAngle   += 90;
                rotation    = -90;
            }

            return(new Ellipse()
            {
                Center = new Vector3(_cx, _cy, 0),
                MajorAxis = major,
                MinorAxis = minor,
                StartAngle = startAngle,
                EndAngle = endAngle,
                Rotation = rotation
            });
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public override void Draw(object dc, Core2D.Shapes.XArc arc, double dx, double dy, ImmutableArray <Core2D.Data.XProperty> db, Core2D.Data.Database.XRecord r)
        {
            var _gfx = dc as XGraphics;

            var a = Core2D.Math.Arc.GdiArc.FromXArc(arc, dx, dy);

            if (arc.IsFilled)
            {
                var path = new XGraphicsPath();
                // NOTE: Not implemented in PdfSharp Core version.
                path.AddArc(
                    _scaleToPage(a.X),
                    _scaleToPage(a.Y),
                    _scaleToPage(a.Width),
                    _scaleToPage(a.Height),
                    a.StartAngle,
                    a.SweepAngle);

                if (arc.IsStroked)
                {
                    _gfx.DrawPath(
                        ToXPen(arc.Style, _scaleToPage, _sourceDpi, _targetDpi),
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
                else
                {
                    _gfx.DrawPath(
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
            }
            else
            {
                if (arc.IsStroked)
                {
                    _gfx.DrawArc(
                        ToXPen(arc.Style, _scaleToPage, _sourceDpi, _targetDpi),
                        _scaleToPage(a.X),
                        _scaleToPage(a.Y),
                        _scaleToPage(a.Width),
                        _scaleToPage(a.Height),
                        a.StartAngle,
                        a.SweepAngle);
                }
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public override void Draw(object dc, Core2D.Shapes.XArc arc, double dx, double dy, ImmutableArray <Core2D.Data.XProperty> db, Core2D.Data.Database.XRecord r)
        {
            var dxf   = dc as DxfDocument;
            var style = arc.Style;

            var dxfEllipse = CreateEllipticalArc(arc, dx, dy);

            if (arc.IsFilled)
            {
                var fill             = ToColor(style.Fill);
                var fillTransparency = ToTransparency(style.Fill);

                // TODO: The netDxf does not create hatch for Ellipse with end angle equal to 360.
                var bounds =
                    new List <HatchBoundaryPath>
                {
                    new HatchBoundaryPath(
                        new List <EntityObject>
                    {
                        (Ellipse)dxfEllipse.Clone()
                    })
                };

                var hatch = new Hatch(HatchPattern.Solid, bounds, false);
                hatch.Layer = _currentLayer;
                hatch.Color = fill;
                hatch.Transparency.Value = fillTransparency;

                dxf.AddEntity(hatch);
            }

            if (arc.IsStroked)
            {
                var stroke            = ToColor(style.Stroke);
                var strokeTansparency = ToTransparency(style.Stroke);
                var lineweight        = ToLineweight(style.Thickness);

                dxfEllipse.Layer = _currentLayer;
                dxfEllipse.Color = stroke;
                dxfEllipse.Transparency.Value = strokeTansparency;
                dxfEllipse.Lineweight         = lineweight;

                dxf.AddEntity(dxfEllipse);
            }
        }