Example #1
0
        public void DrawRoundedRectangle(Point start, double width, double height, double radius, bool strokeAndFill)
        {
            double x, y;

            x       = start.X + LineWidth / 2;
            y       = start.Y + LineWidth / 2;
            height -= LineWidth;
            width  -= LineWidth;

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            CContext.MoveTo(x, y + radius);
            CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            CContext.LineTo(x + width - radius, y);
            CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            CContext.LineTo(x + width, y + height - radius);
            CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            CContext.LineTo(x + radius, y + height);
            CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            CContext.ClosePath();
            if (strokeAndFill)
            {
                StrokeAndFill();
            }
        }
Example #2
0
 public void DrawCircleImage(Point center, double radius, Image image)
 {
     DrawCircle(center, radius);
     CContext.Save();
     CContext.Arc(center.X, center.Y, radius, 0, 2 * Math.PI);
     CContext.Clip();
     DrawImage(new Point(center.X - radius, center.Y - radius), radius * 2, radius * 2, image,
               ScaleMode.AspectFill, false);
     CContext.Restore();
 }
Example #3
0
        public void DrawEllipse(Point center, double axisX, double axisY)
        {
            double max = Math.Max(axisX, axisY);

            CContext.Save();
            CContext.Translate(center.X, center.Y);
            CContext.Scale(axisX / max, axisY / max);
            CContext.Arc(0, 0, max, 0, 2 * Math.PI);
            StrokeAndFill();
            CContext.Restore();
        }
Example #4
0
        public void ClipRoundRectangle(Point start, double width, double height, double radius)
        {
            double x, y;

            x = start.X;
            y = start.Y;

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            CContext.MoveTo(x, y + radius);
            CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            CContext.LineTo(x + width - radius, y);
            CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            CContext.LineTo(x + width, y + height - radius);
            CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            CContext.LineTo(x + radius, y + height);
            CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            CContext.ClosePath();
            CContext.Clip();
        }
Example #5
0
 public void DrawCircle(Point center, double radius)
 {
     CContext.Arc(center.X, center.Y, radius, 0, 2 * Math.PI);
     StrokeAndFill();
 }
Example #6
0
 public void DrawArc(Point center, double radius, double angle1, double angle2)
 {
     CContext.Arc(center.X, center.Y, radius, angle1, angle2);
     StrokeAndFill(false);
 }
Example #7
0
 public void ClipCircle(Point center, double radius)
 {
     CContext.Arc(center.X, center.Y, radius, 0, 2 * Math.PI);
     CContext.Clip();
 }