示例#1
0
 public void FillRectangle(Brush brush, float x, float y, float width, float height)
 {
     StartDrawing();
     brush.Apply(this);
     Control.FillRect(TranslateView(new CGRect(x, y, width, height), width > 1 || height > 1, true));
     EndDrawing();
 }
示例#2
0
 public void FillRectangle(Brush brush, float x, float y, float width, float height)
 {
     Control.Rectangle(x + inverseoffset, y + inverseoffset, width, height);
     Control.Save();
     brush.Apply(this);
     Control.Restore();
 }
示例#3
0
        public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
        {
            SetOffset(true);
            Control.Save();
            Control.Translate(x + width / 2, y + height / 2);
            double radius = Math.Max(width / 2.0, height / 2.0);

            if (width > height)
            {
                Control.Scale(1.0, height / width);
            }
            else
            {
                Control.Scale(width / height, 1.0);
            }
            if (sweepAngle < 0)
            {
                Control.ArcNegative(0, 0, radius, Conversions.DegreesToRadians(startAngle), Conversions.DegreesToRadians(startAngle + sweepAngle));
            }
            else
            {
                Control.Arc(0, 0, radius, Conversions.DegreesToRadians(startAngle), Conversions.DegreesToRadians(startAngle + sweepAngle));
            }
            Control.LineTo(0, 0);
            Control.Restore();
            Control.Save();
            brush.Apply(this);
            Control.Fill();
            Control.Restore();
        }
示例#4
0
 public void FillRectangle(Brush brush, float x, float y, float width, float height)
 {
     SetOffset(true);
     Control.Rectangle(x, y, width, height);
     Control.Save();
     brush.Apply(this);
     Control.Restore();
 }
示例#5
0
 public void FillPath(Brush brush, IGraphicsPath path)
 {
     SetOffset(true);
     Control.Save();
     path.Apply(Control);
     Control.FillRule = path.FillMode.ToCairo();
     brush.Apply(this);
     Control.Restore();
 }
示例#6
0
 public void FillPath(Brush brush, IGraphicsPath path)
 {
     Control.Save();
     Control.Translate(inverseoffset, inverseoffset);
     path.Apply(Control);
     Control.Restore();
     Control.Save();
     Control.FillRule = path.FillMode.ToCairo();
     brush.Apply(this);
     Control.Restore();
 }
示例#7
0
 public void Apply(Cairo.Context context)
 {
     context.LineWidth = Thickness;
     context.LineCap   = LineCap;
     context.LineJoin  = LineJoin;
     if (cairodashes != null)
     {
         context.SetDash(cairodashes, cairooffset);
     }
     context.MiterLimit = MiterLimit;
     Brush.Apply(context);
 }
示例#8
0
文件: PenHandler.cs 项目: nzysoft/Eto
 public void Apply(GraphicsHandler graphics)
 {
     graphics.Control.LineWidth = Thickness;
     graphics.Control.LineCap   = LineCap;
     graphics.Control.LineJoin  = LineJoin;
     if (cairodashes != null)
     {
         graphics.Control.SetDash(cairodashes, cairooffset);
     }
     graphics.Control.MiterLimit = MiterLimit;
     Brush.Apply(graphics);
 }
示例#9
0
        public void FillEllipse(Brush brush, float x, float y, float width, float height)
        {
            StartDrawing();

            /*	if (width == 1 || height == 1)
             * {
             *      DrawLine(color, x, y, x+width-1, y+height-1);
             *      return;
             * }*/

            brush.Apply(this);
            Control.FillEllipseInRect(TranslateView(new CGRect(x, y, width, height), true, true));
            EndDrawing();
        }
示例#10
0
        public void DrawText(Font font, Brush brush, float x, float y, string text)
        {
            var oldAA = AntiAlias;

            AntiAlias = true;
            SetOffset(false);
            using (var layout = CreateLayout())
            {
                font.Apply(layout);
                layout.SetText(text);
                Control.Save();
                brush.Apply(this);
                Control.MoveTo(x, y);
                Pango.CairoHelper.LayoutPath(Control, layout);
                Control.Fill();
                Control.Restore();
            }
            AntiAlias = oldAA;
        }
示例#11
0
        public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
        {
            StartDrawing();

            var rect = TranslateView(new CGRect(x, y, width, height), true, true);

            brush.Apply(this);
            var yscale  = rect.Height / rect.Width;
            var centerY = rect.GetMidY();
            var centerX = rect.GetMidX();

            Control.ConcatCTM(new CGAffineTransform(1.0f, 0, 0, yscale, 0, centerY - centerY * yscale));
            Control.MoveTo(centerX, centerY);
            Control.AddArc(centerX, centerY, rect.Width / 2, Conversions.DegreesToRadians(startAngle), Conversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
            Control.AddLineToPoint(centerX, centerY);
            Control.ClosePath();
            Control.FillPath();
            EndDrawing();
        }
示例#12
0
        public void FillEllipse(Brush brush, float x, float y, float width, float height)
        {
            Control.Save();
            Control.Translate(x + width / 2 + inverseoffset, y + height / 2 + inverseoffset);
            double radius = Math.Max(width / 2.0, height / 2.0);

            if (width > height)
            {
                Control.Scale(1.0, height / width);
            }
            else
            {
                Control.Scale(width / height, 1.0);
            }
            Control.Arc(0, 0, radius, 0, 2 * Math.PI);
            Control.Restore();
            Control.Save();
            brush.Apply(this);
            Control.Restore();
        }
示例#13
0
        public void FillPath(Brush brush, IGraphicsPath path)
        {
            StartDrawing();

            Control.TranslateCTM(inverseoffset, inverseoffset);
            Control.BeginPath();
            Control.AddPath(path.ToCG());
            Control.ClosePath();
            brush.Apply(this);
            switch (path.FillMode)
            {
            case FillMode.Alternate:
                Control.EOFillPath();
                break;

            case FillMode.Winding:
                Control.FillPath();
                break;

            default:
                throw new NotSupportedException();
            }
            EndDrawing();
        }
示例#14
0
		public void FillRectangle(Brush brush, float x, float y, float width, float height)
		{
			StartDrawing();
			brush.Apply(this);
			Control.FillRect(TranslateView(new CGRect(x, y, width, height), width > 1 || height > 1, true));
			EndDrawing();
		}
示例#15
0
		public void FillEllipse(Brush brush, float x, float y, float width, float height)
		{
			StartDrawing();
			/*	if (width == 1 || height == 1)
			{
				DrawLine(color, x, y, x+width-1, y+height-1);
				return;
			}*/

			brush.Apply(this);
			Control.FillEllipseInRect(TranslateView(new CGRect(x, y, width, height), true, true));
			EndDrawing();
		}
示例#16
0
		public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
		{
			StartDrawing();

			var rect = TranslateView(new CGRect(x, y, width, height), true, true);
			brush.Apply(this);
			var yscale = rect.Height / rect.Width;
			var centerY = rect.GetMidY();
			var centerX = rect.GetMidX();
			Control.ConcatCTM(new CGAffineTransform(1.0f, 0, 0, yscale, 0, centerY - centerY * yscale));
			Control.MoveTo(centerX, centerY);
			Control.AddArc(centerX, centerY, rect.Width / 2, Conversions.DegreesToRadians(startAngle), Conversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
			Control.AddLineToPoint(centerX, centerY);
			Control.ClosePath();
			Control.FillPath();
			EndDrawing();
		}
示例#17
0
 public static void Apply(this Brush brush, GraphicsHandler graphics) => brush.Apply(graphics.Control);
示例#18
0
		public void FillPath(Brush brush, IGraphicsPath path)
		{
			StartDrawing();

			Control.TranslateCTM(inverseoffset, inverseoffset);
			Control.BeginPath();
			Control.AddPath(path.ToCG());
			Control.ClosePath();
			brush.Apply(this);
			switch (path.FillMode)
			{
				case FillMode.Alternate:
					Control.EOFillPath();
					break;
				case FillMode.Winding:
					Control.FillPath();
					break;
				default:
					throw new NotSupportedException();
			}
			EndDrawing();
		}