Example #1
0
        public void RoundedRectangle(Rectangle rectangle, double cornerRadius)
        {
            if (Filling)
            {
                // adjust corner radius if we do stroke afterwards.

                var filledCornerRadius = Stroking
                                        ? Math.Max(0, cornerRadius - _state.StrokeWeight / 2)
                                        : cornerRadius;

                var roundedRect = new RoundedRect
                {
                    Rect    = fillRect(rectangle),
                    RadiusX = filledCornerRadius.import(),
                    RadiusY = filledCornerRadius.import()
                };

                _target.FillRoundedRectangle(roundedRect, _fillBrush.Brush);
            }

            if (Stroking)
            {
                var roundedRect = new RoundedRect
                {
                    Rect    = strokeAlignedRect(rectangle),
                    RadiusX = cornerRadius.import(),
                    RadiusY = cornerRadius.import()
                };

                _target.DrawRoundedRectangle(roundedRect, _strokeBrush.Brush, StrokeWeight);
            }
        }
Example #2
0
        RectangleF fillRect(Rectangle rectangle)
        {
            if (!Stroking)
            {
                return(new RectangleF(rectangle.X.import(), rectangle.Y.import(), rectangle.Right.import(), rectangle.Bottom.import()));
            }

            return(_state.StrokeFillBounds(rectangle).import());
        }
Example #3
0
 public void Arc(Rectangle rectangle, double start, double stop)
 {
     if (Stroking)
     {
         var r            = strokeAlignedRect(rectangle);
         var currentPoint = ArcGeometry.pointOn(r, start);
         drawOpenPath(currentPoint, sink => ArcGeometry.add(r, start, stop, sink));
     }
 }
Example #4
0
        public void Rectangle(Rectangle rectangle)
        {
            if (Filling)
            {
                var r = fillRect(rectangle);
                _target.FillRectangle(r, _fillBrush.Brush);
            }

            if (Stroking)
            {
                var r = strokeAlignedRect(rectangle);
                _target.DrawRectangle(r, _strokeBrush.Brush, StrokeWeight);
            }
        }
Example #5
0
        public void Ellipse(Rectangle rectangle)
        {
            if (Filling)
            {
                var r       = fillRect(rectangle);
                var ellipse = new Ellipse(Import.Point(r.Left + r.Width / 2, r.Top + r.Height / 2), r.Width / 2, r.Height / 2);
                _target.FillEllipse(ellipse, _fillBrush.Brush);
            }

            if (Stroking)
            {
                var r       = strokeAlignedRect(rectangle);
                var ellipse = new Ellipse(Import.Point(r.Left + r.Width / 2, r.Top + r.Height / 2), r.Width / 2, r.Height / 2);
                _target.DrawEllipse(ellipse, _strokeBrush.Brush, StrokeWeight);
            }
        }
Example #6
0
 public static RectangleF Rectangle(Rectangle r)
 {
     return(new RectangleF(r.X.import(), r.Y.import(), r.Right.import(), r.Bottom.import()));
 }
Example #7
0
 public void Arc(Rectangle rectangle, double start, double stop)
 {
     if (Stroking)
     {
         var r = strokeAlignedRect(rectangle);
         var currentPoint = ArcGeometry.pointOn(r, start);
         drawOpenPath(currentPoint, sink => ArcGeometry.add(r, start, stop, sink));
     }
 }
Example #8
0
 RectangleF strokeAlignedRect(Rectangle rectangle)
 {
     return _state.StrokeAlignedBounds(rectangle).import();
 }
Example #9
0
        RectangleF fillRect(Rectangle rectangle)
        {
            if (!Stroking)
            {
                return new RectangleF(rectangle.X.import(), rectangle.Y.import(), rectangle.Width.import(), rectangle.Height.import());
            }

            return _state.StrokeFillBounds(rectangle).import();
        }
Example #10
0
        public void RoundedRectangle(Rectangle rectangle, Size cornerRadius)
        {
            if (Filling)
            {
                // adjust corner radius if we do stroke afterwards.

                var filledCornerRadiusX = Stroking
                    ? Math.Max(0, cornerRadius.Width - _state.StrokeWeight/2)
                    : cornerRadius.Width;

                var filledCornerRadiusY = Stroking
                    ? Math.Max(0, cornerRadius.Height - _state.StrokeWeight / 2)
                    : cornerRadius.Height;

                var roundedRect = new RoundedRectangle
                {
                    Rect = fillRect(rectangle),
                    RadiusX = filledCornerRadiusX.import(),
                    RadiusY = filledCornerRadiusY.import()
                };

                _target.FillRoundedRectangle(roundedRect, _fillBrush.Brush);
            }

            if (Stroking)
            {
                var roundedRect = new RoundedRectangle
                {
                    Rect = strokeAlignedRect(rectangle),
                    RadiusX = cornerRadius.Width.import(),
                    RadiusY = cornerRadius.Height.import()
                };

                _target.DrawRoundedRectangle(roundedRect, _strokeBrush.Brush, StrokeWeight);
            }
        }
Example #11
0
        public void Rectangle(Rectangle rectangle)
        {
            if (Filling)
            {
                var r = fillRect(rectangle);
                _target.FillRectangle(r, _fillBrush.Brush);
            }

            if (Stroking)
            {
                var r = strokeAlignedRect(rectangle);
                _target.DrawRectangle(r, _strokeBrush.Brush, StrokeWeight);
            }
        }
Example #12
0
        public void Ellipse(Rectangle rectangle)
        {
            if (Filling)
            {
                var r = fillRect(rectangle);
                var ellipse = new Ellipse(Import.Point(r.Left + r.Width/2, r.Top + r.Height/2), r.Width/2, r.Height/2);
                _target.FillEllipse(ellipse, _fillBrush.Brush);
            }

            if (Stroking)
            {
                var r = strokeAlignedRect(rectangle);
                var ellipse = new Ellipse(Import.Point(r.Left + r.Width / 2, r.Top + r.Height / 2), r.Width / 2, r.Height / 2);
                _target.DrawEllipse(ellipse, _strokeBrush.Brush, StrokeWeight);
            }
        }
Example #13
0
 RectangleF strokeAlignedRect(Rectangle rectangle)
 {
     return(_state.StrokeAlignedBounds(rectangle).import());
 }
Example #14
0
 public static RectangleF Rectangle(Rectangle r)
 {
     return new RectangleF(r.X.import(), r.Y.import(), r.Width.import(), r.Height.import());
 }