当前位置: 首页>>代码示例>>C#>>正文


C# Context.ArcNegative方法代码示例

本文整理汇总了C#中Cairo.Context.ArcNegative方法的典型用法代码示例。如果您正苦于以下问题:C# Context.ArcNegative方法的具体用法?C# Context.ArcNegative怎么用?C# Context.ArcNegative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cairo.Context的用法示例。


在下文中一共展示了Context.ArcNegative方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: arc_negative

		public void arc_negative(Context cr, int width, int height)
		{
			PointD c = new PointD(0.5, 0.5);
			double radius = 0.4;
			double angle1 = 45.0  * (Math.PI/180.0);  /* angles are specified */
			double angle2 = 180.0 * (Math.PI/180.0);  /* in radians           */

			Normalize(cr, width, height);

			cr.ArcNegative(c.X, c.Y, radius, angle1, angle2);
			cr.Stroke();

			// draw helping lines
			cr.Color = new Color (1, 0.2, 0.2, 0.6);
			cr.Arc(c.X, c.Y, 0.05, 0, 2*Math.PI);
			cr.Fill();
			cr.LineWidth = 0.03;
			cr.Arc(c.X, c.Y, radius, angle1, angle1);
			cr.LineTo(c);
			cr.Arc(c.X, c.Y, radius, angle2, angle2);
			cr.LineTo(c);
			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:23,代码来源:Snippets.cs

示例2: GeneratePuzzlePiece

 public static Gdk.Pixbuf GeneratePuzzlePiece(TypeColors tc, int size)
 {
     Gdk.Pixbuf pb;
     using (ImageSurface imsu = new ImageSurface (Format.ARGB32, size, size)) {
         using (Context ctx = new Context (imsu)) {
             ctx.Color = White;
             ctx.Paint ();
             double x1 = 0.9d * size, x0 = size - x1, x2 = 0.35d * size, x3 = 0.55d * size, x4 = 0.45d * size;
             ctx.MoveTo (0.0d, x0);
             ctx.LineTo (x2, x0);
             ctx.Arc (x4, x0, x0, Math.PI, 2.0d * Math.PI);
             ctx.LineTo (x1, x0);
             ctx.LineTo (x1, x2 + x0);
             ctx.Arc (x1, x4 + x0, x0, 1.5d * Math.PI, 2.5d * Math.PI);
             ctx.LineTo (x1, size);
             ctx.LineTo (x3, size);
             ctx.ArcNegative (x4, size, x0, 2.0d * Math.PI, Math.PI);
             ctx.LineTo (0.0d, size);
             ctx.LineTo (0.0d, x3 + x0);
             ctx.ArcNegative (0.0d, x4 + x0, x0, 2.5d * Math.PI, 1.5d * Math.PI);
             ctx.ClosePath ();
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern (size, tc);
             ctx.Fill ();
             byte a, r, g, b;
             byte[] dat = new byte[imsu.Data.Length];
             for (int i = 0, j = 0; i < dat.Length;) {
                 b = imsu.Data [i++];
                 g = imsu.Data [i++];
                 r = imsu.Data [i++];
                 a = imsu.Data [i++];
                 dat [j++] = r;
                 dat [j++] = g;
                 dat [j++] = b;
                 dat [j++] = a;
             }
             pb = new Gdk.Pixbuf(dat,Gdk.Colorspace.Rgb,true,8,size,size,imsu.Stride);
         }
     }
     return pb;
 }
开发者ID:KommuSoft,项目名称:CplKul2012,代码行数:40,代码来源:KnownColors.cs

示例3: Draw


//.........这里部分代码省略.........
					}

					//square angle
					arcCenter.X = 0.5 * (arc.Middle.GeometryX + arc.End.GeometryX);
					arcCenter.Y = 0.5 * (arc.Start.GeometryY + arc.Middle.GeometryY);
				}

				if (Math.Abs(yDeltaA) <= eps)
				{
					//1st is horizontal
					if (Math.Abs(yDeltaB) <= eps)
					{
						//2nd is horizontal too
						//throw new ArgumentException("Both line are horizontal");
						return;
					}

					if (Math.Abs(xDeltaB) > eps)
					{
						//1st is not horizontal
						//throw new NotImplementedException("Only first horizontal");
						return;
					}

					//square angle
					arcCenter.X = 0.5 * (arc.Start.GeometryX + arc.Middle.GeometryX);
					arcCenter.Y = 0.5 * (arc.Middle.GeometryY + arc.End.GeometryY);
				}
			}

			//radius
			var arcRadius = Math.Sqrt(Math.Pow(arc.Start.GeometryX - arcCenter.X, 2)
			                             + Math.Pow(arc.Start.GeometryY - arcCenter.Y, 2));

			//arc angles
			var xStartDelta = arc.Start.GeometryX - arcCenter.X;
			var yStartDelta = arc.Start.GeometryY - arcCenter.Y;

			var xEndDelta = arc.End.GeometryX - arcCenter.X;
			var yEndDelta = arc.End.GeometryY - arcCenter.Y;

			//start of arc
			if (Math.Abs(xStartDelta) < eps)
			{
				if (yStartDelta < 0.0)
				{
					arcStart = -0.5 * Math.PI;
				}
				else
				{
					arcStart = 0.5 * Math.PI;
				}
			}
			else
			{
				arcStart = Math.Atan2(yStartDelta, xStartDelta);
			}

			//end of arc
			if (Math.Abs(xEndDelta) < eps)
			{
				if (yEndDelta < 0.0)
				{
					arcEnd = -0.5 * Math.PI;
				}
				else
				{
					arcEnd = 0.5 * Math.PI;
				}
			}
			else
			{
				arcEnd = Math.Atan2(yEndDelta, xEndDelta);
			}

			if (Math.Sign((arc.Middle.GeometryX - arc.Start.GeometryX)
				* (arc.Middle.GeometryY - arc.End.GeometryY)
				- (arc.Middle.GeometryY - arc.Start.GeometryY)
				* (arc.Middle.GeometryX - arc.End.GeometryX)) < 0)
			{
				grw.Arc(
					arcCenter.X,
					arcCenter.Y,
					arcRadius,
					arcStart,
					arcEnd);
			}
			else
			{
				grw.ArcNegative(
					arcCenter.X,
					arcCenter.Y,
					arcRadius,
					arcStart,
					arcEnd);
			}


			grw.Stroke();
		}
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:101,代码来源:Arc3PointsBrush.cs

示例4: DrawRibbon

        /// <summary>Draws a ribbon.</summary>
        public void DrawRibbon(Context cr, Gdk.Rectangle menuBarAllocation, Gdk.Rectangle bodyAllocation, double roundSize, double lineWidth, Ribbon widget)
        {
            double lineWidth05 = lineWidth / 2;
            double lineWidth15 = 3 * lineWidth05;
            double x0, x1, y0, y1;
            LinearGradient linGrad;

            if(menuBarAllocation.Height > 0)
            {
                cr.Rectangle (menuBarAllocation.X, menuBarAllocation.Y, menuBarAllocation.Width, menuBarAllocation.Height - 1);
                linGrad = new LinearGradient (0, menuBarAllocation.Y, 0, menuBarAllocation.Y + menuBarAllocation.Height - 1);
                linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.5));
                linGrad.AddColorStop (0.3, new Color (1, 1, 1, 0.2));
                linGrad.AddColorStop (0.3, new Color (1, 1, 1, 0.0));
                linGrad.AddColorStop (1.0, new Color (1, 1, 1, 0.5));
                cr.Pattern = linGrad;
                cr.Fill ();
                linGrad.Destroy ();

                cr.MoveTo (menuBarAllocation.X, menuBarAllocation.Bottom + 0.5);
                cr.LineTo (menuBarAllocation.Right, menuBarAllocation.Bottom + 0.5);
                cr.Color = new Color (1, 1, 1, 0.5);
                cr.LineWidth = 1;
                cr.Stroke ();

                // Quick Access Toolbar background

                Gdk.Rectangle alloc = widget.QuickAccessToolbar.Allocation;
                x0 = alloc.X;
                x1 = alloc.Right - 1;
                y0 = alloc.Y;
                y1 = alloc.Bottom - 1;
                double radius = (y1 - y0) / 2;

                cr.LineWidth = 1;

                if(widget.ApplicationButton != null)
                {
                    Gdk.Rectangle alloc2 = widget.ApplicationButton.Allocation;
                    double cx = alloc2.X + alloc2.Width / 2;
                    double cy = alloc2.Y + alloc2.Height / 2;
                    double radius2 = x0 - cx;
                    double alpha = Math.Asin ((y0 - cy) / radius2);
                    double beta = Math.Asin ((y1 - cy) / radius2);
                    double curveWidth0 = Math.Cos (Math.Abs (alpha)) * radius2;
                    double curveWidth1 = Math.Cos (Math.Abs (beta)) * radius2;
                    double curveWidth = Math.Min (curveWidth0, curveWidth1);

                    cr.Save ();
                    cr.Rectangle (cx + curveWidth, y0, x1 - cx - curveWidth, alloc.Height);
                    cr.ClipPreserve ();
                    cr.ArcNegative (cx, cy, radius2, -alpha, -beta);
                    linGrad = new LinearGradient (0, y0, 0, y1);
                    linGrad.AddColorStop (0.0, colorScheme.Bright);
                    linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                    cr.Pattern = linGrad;
                    //cr.Color = new Color (1, 0, 0);
                    cr.Fill ();
                    cr.Restore ();
                    cr.Arc (x1, y0 + radius, radius - 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
                    cr.Pattern = linGrad;
                    cr.Fill ();
                    linGrad.Destroy ();

                    cr.Arc (cx, cy, radius2, alpha, beta);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();
                    radius2 -= 1;
                    cr.Arc (cx, cy, radius2, alpha, beta);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth0, y0 - 0.5);
                    cr.LineTo (x1, y0 - 0.5);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth0, y0 + 0.5);
                    cr.LineTo (x1, y0 + 0.5);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth1, y1 - 0.5);
                    cr.LineTo (x1, y1 - 0.5);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth1, y1 + 0.5);
                    cr.LineTo (x1, y1 + 0.5);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();
                }
                else
                {
                    cr.Rectangle (x0, y0, x1 - x0, alloc.Height);
                    linGrad = new LinearGradient (0, y0, 0, y1);
                    linGrad.AddColorStop (0.0, colorScheme.Bright);
                    linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                    cr.Pattern = linGrad;
//.........这里部分代码省略.........
开发者ID:MASGAU,项目名称:gtk-sharp-ribbon,代码行数:101,代码来源:Theme.cs


注:本文中的Cairo.Context.ArcNegative方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。