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


C# Context.CurveTo方法代码示例

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


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

示例1: OnMouseMove

		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			int line_width = (int)g.LineWidth;
			int size;

			// we want a minimum size of 2 for the splatter (except for when the brush width is 1), since a splatter of size 1 is very small
			if (line_width == 1)
			{
				size = 1;
			}
			else
			{
				size = Random.Next (2, line_width);
			}

			Rectangle r = new Rectangle (x - Random.Next (-15, 15), y - Random.Next (-15, 15), size, size);

			double rx = r.Width / 2;
			double ry = r.Height / 2;
			double cx = r.X + rx;
			double cy = r.Y + ry;
			double c1 = 0.552285;

			g.Save ();

			g.MoveTo (cx + rx, cy);

			g.CurveTo (cx + rx, cy - c1 * ry, cx + c1 * rx, cy - ry, cx, cy - ry);
			g.CurveTo (cx - c1 * rx, cy - ry, cx - rx, cy - c1 * ry, cx - rx, cy);
			g.CurveTo (cx - rx, cy + c1 * ry, cx - c1 * rx, cy + ry, cx, cy + ry);
			g.CurveTo (cx + c1 * rx, cy + ry, cx + rx, cy + c1 * ry, cx + rx, cy);

			g.ClosePath ();

			Rectangle dirty = g.FixedStrokeExtents ();

			g.Fill ();
			g.Restore ();

			return dirty.ToGdkRectangle ();
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:42,代码来源:SplatterBrush.cs

示例2: OnPaint

 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     using (System.Drawing.Graphics graphics = e.Graphics)
     {
         using (Win32Surface surface = new Win32Surface(graphics.GetHdc()))
         {
             using (Context context = new Context(surface))
             {
                 context.LineWidth = 2.0;
                 context.SetSourceColor(this.bugColor);
                 context.MoveTo(7.0, 64.0);
                 context.CurveTo(1.0, 47.0, 2.0, 46.0, 9.0, 51.0);
                 context.MoveTo(25.0, 80.0);
                 context.CurveTo(10.0, 73.0, 11.0, 70.0, 14.0, 63.0);
                 context.MoveTo(10.0, 41.0);
                 context.CurveTo(2.0, 36.0, 1.0, 33.0, 1.0, 26.0);
                 context.LineWidth = 1.0;
                 context.MoveTo(1.0, 26.0);
                 context.CurveTo(5.0, 23.0, 7.0, 18.0, 12.0, 17.0);
                 context.LineTo(12.0, 14.0);
                 context.Stroke();
                 context.MoveTo(30.0, 74.0);
                 context.CurveTo(14.0, 64.0, 10.0, 48.0, 11.0, 46.0);
                 context.LineTo(10.0, 45.0);
                 context.LineTo(10.0, 40.0);
                 context.CurveTo(13.0, 37.0, 15.0, 35.0, 19.0, 34.0);
                 context.Stroke();
             }
         }
     }
 }
开发者ID:zwcloud,项目名称:CairoSharp,代码行数:32,代码来源:Form1.cs

示例3: Execute

		public void Execute(Context ctx)
		{
			PointD point;
			var first = true;

			using (var mpath = ctx.CopyPath())
			{
				var path = mpath.GetPath();

				for (var i = 0; i < path.num_data; )
				{
					var hdr = path.GetPathHeader(i); //hdr.Dump();

					switch (hdr.type)
					{
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_MOVE_TO:
							if (first)
							{
								ctx.NewPath();
								first = false;
							}
							point = path.GetPathPoint(i + 1);
							ctx.MoveTo(WarpPoint(point));
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_LINE_TO:
							point = path.GetPathPoint(i + 1);
							ctx.LineTo(WarpPoint(point));
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_CURVE_TO:
							var p1 = WarpPoint(path.GetPathPoint(i + 1));
							var p2 = WarpPoint(path.GetPathPoint(i + 2));
							var p3 = WarpPoint(path.GetPathPoint(i + 3));
							ctx.CurveTo(p1, p2, p3);
							break;
						case NativePath.cairo_path_data_type_t.CAIRO_PATH_CLOSE_PATH:
							ctx.ClosePath();
							break;
					}

					i += hdr.length;
				}
			}
		}
开发者ID:pruiz,项目名称:Mono.CairoWarp,代码行数:43,代码来源:Warp.cs

示例4: LayoutTabBorder

		static void LayoutTabBorder (Context ctx, Gdk.Rectangle allocation, int contentWidth, int px, int margin, bool active = true)
		{
			double x = 0.5 + (double)px;
			double y = (double)allocation.Height + 0.5 - BottomBarPadding + margin;
			double height = allocation.Height - TopBarPadding - BottomBarPadding;

			x += TabSpacing + margin;
			contentWidth -= (TabSpacing + margin) * 2;

			double rightx = x + contentWidth;

			int lean = Math.Min (LeanWidth, contentWidth / 2);
			int halfLean = lean / 2;
			const int smoothing = 2;
			if (active) {
				ctx.MoveTo (0, y + 0.5);
				ctx.LineTo (0, y);
				ctx.LineTo (x - halfLean, y);
			} else {
				ctx.MoveTo (x - halfLean, y + 0.5);
				ctx.LineTo (x - halfLean, y);
			}
			ctx.CurveTo (new PointD (x + smoothing, y),
				new PointD (x - smoothing, y - height),
				new PointD (x + halfLean, y - height));
			ctx.LineTo (rightx - halfLean, y - height);
			ctx.CurveTo (new PointD (rightx + smoothing, y - height),
				new PointD (rightx - smoothing, y),
				new PointD (rightx + halfLean, y));

			if (active) {
				ctx.LineTo (allocation.Width, y);
				ctx.LineTo (allocation.Width, y + 0.5);
			} else {
				ctx.LineTo (rightx + halfLean, y + 0.5);
			}
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:37,代码来源:TabStrip.cs

示例5: xxx_dash

		public void xxx_dash(Context cr, int width, int height)
		{
			double[] dashes = new double[] {
				0.20,  // ink
				0.05,  // skip
				0.05,  // ink
				0.05   // skip 
			};
			double offset = -0.2; 

			Normalize(cr, width, height);

			cr.SetDash(dashes, offset);

			cr.MoveTo(0.5, 0.1);
			cr.LineTo(0.9, 0.9);
			cr.RelLineTo(-0.4, 0.0);
			cr.CurveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:20,代码来源:Snippets.cs

示例6: path

		public void path(Context cr, int width, int height)
		{
			Normalize(cr, width, height);
			cr.MoveTo(0.5, 0.1);
			cr.LineTo(0.9, 0.9);
			cr.RelLineTo(-0.4, 0.0);
			cr.CurveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);

			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:10,代码来源:Snippets.cs

示例7: fill_and_stroke2

		public void fill_and_stroke2(Context cr, int width, int height)
		{
			Normalize (cr, width, height);

			cr.MoveTo(0.5, 0.1);
			cr.LineTo(0.9, 0.9);
			cr.RelLineTo(-0.4, 0.0);
			cr.CurveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
			cr.ClosePath();

			cr.MoveTo(0.25, 0.1);
			cr.RelLineTo(0.2, 0.2);
			cr.RelLineTo(-0.2, 0.2);
			cr.RelLineTo(-0.2, -0.2);
			cr.ClosePath();

			cr.Color = new Color (0, 0, 1);
			cr.FillPreserve();
			cr.Color = new Color (0, 0, 0);

			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:22,代码来源:Snippets.cs

示例8: curve_rectangle

		public void curve_rectangle(Context cr, int width, int height)
		{
			// a custom shape, that could be wrapped in a function
			double x0	   = 0.1,   //< parameters like cairo_rectangle
			       y0	   = 0.1,
			       rect_width  = 0.8,
		    	   rect_height = 0.8,
				   radius = 0.4;   //< and an approximate curvature radius

			double x1,y1;

			Normalize(cr, width, height);

			x1=x0+rect_width;
			y1=y0+rect_height;

			if (rect_width/2<radius) {
				if (rect_height/2<radius) {
					cr.MoveTo(x0, (y0 + y1)/2);
					cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
					cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
				} else {
					cr.MoveTo(x0, y0 + radius);
					cr.CurveTo(x0 ,y0, x0, y0, (x0 + x1)/2, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius);
					cr.LineTo(x1 , y1 - radius);
					cr.CurveTo(x1, y1, x1, y1, (x1 + x0)/2, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, y1- radius);
				}
			} else {
				if (rect_height/2<radius) {
					cr.MoveTo(x0, (y0 + y1)/2);
					cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0);
					cr.LineTo(x1 - radius, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, (y0 + y1)/2);
					cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
					cr.LineTo(x0 + radius, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, (y0 + y1)/2);
				} else {
					cr.MoveTo(x0, y0 + radius);
					cr.CurveTo(x0 , y0, x0 , y0, x0 + radius, y0);
					cr.LineTo(x1 - radius, y0);
					cr.CurveTo(x1, y0, x1, y0, x1, y0 + radius);
					cr.LineTo(x1 , y1 - radius);
					cr.CurveTo(x1, y1, x1, y1, x1 - radius, y1);
					cr.LineTo(x0 + radius, y1);
					cr.CurveTo(x0, y1, x0, y1, x0, y1- radius);
				}
			}
			cr.ClosePath();

			// and fill/stroke it
			cr.Color = new Color (0.5, 0.5, 1);
			cr.FillPreserve();
			cr.Color = new Color (0.5, 0, 0, 0.5);
			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:59,代码来源:Snippets.cs

示例9: curve_to

		public void curve_to(Context cr, int width, int height)
		{
			double x=0.1,  y=0.5;
			double x1=0.4, y1=0.9, x2=0.6, y2=0.1, x3=0.9, y3=0.5;

			Normalize (cr, width, height);

			cr.MoveTo(x, y);
			cr.CurveTo(x1, y1, x2, y2, x3, y3);

			cr.Stroke();

			cr.Color = new Color (1, 0.2, 0.2, 0.6);
			cr.LineWidth = 0.03;
			cr.MoveTo(x,y);
			cr.LineTo(x1,y1);
			cr.MoveTo(x2,y2);
			cr.LineTo(x3,y3);
			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:20,代码来源:Snippets.cs

示例10: CreateRoundedRectPath

 public void CreateRoundedRectPath(Context gc, double x, double y, double width, double height, double radius)
 {
     double x1, y1;
     x1 = x + width;
     y1 = y + height;
     if (width / 2 < radius) {
         if (height / 2 < radius) {
             gc.MoveTo (x, (y + y1) / 2);
             gc.CurveTo (x ,y, x, y, (x + x1) / 2, y);
             gc.CurveTo (x1, y, x1, y, x1, (y + y1) / 2);
             gc.CurveTo (x1, y1, x1, y1, (x1 + x) / 2, y1);
             gc.CurveTo (x, y1, x, y1, x, (y + y1) / 2);
         } else {
             gc.MoveTo (x, y + radius);
             gc.CurveTo (x, y, x, y, (x + x1) / 2, y);
             gc.CurveTo (x1, y, x1, y, x1, y + radius);
             gc.LineTo (x1 , y1 - radius);
             gc.CurveTo (x1, y1, x1, y1, (x1 + x) / 2, y1);
             gc.CurveTo (x, y1, x, y1, x, y1 - radius);
         }
     } else {
         if (height / 2 < radius) {
             gc.MoveTo (x, (y + y1) / 2);
             gc.CurveTo (x , y, x, y, x + radius, y);
             gc.LineTo (x1 - radius, y);
             gc.CurveTo (x1, y, x1, y, x1, (y + y1) / 2);
             gc.CurveTo (x1, y1, x1, y1, x1 - radius, y1);
             gc.LineTo (x + radius, y1);
             gc.CurveTo (x, y1, x, y1, x, (y + y1) / 2);
         } else {
             gc.MoveTo (x, y + radius);
             gc.CurveTo (x , y, x , y, x + radius, y);
             gc.LineTo (x1 - radius, y);
             gc.CurveTo (x1, y, x1, y, x1, y + radius);
             gc.LineTo (x1, y1 - radius);
             gc.CurveTo (x1, y1, x1, y1, x1 - radius, y1);
             gc.LineTo (x + radius, y1);
             gc.CurveTo (x, y1, x, y1, x, y1 - radius);
         }
     }
     gc.ClosePath ();
 }
开发者ID:codebutler,项目名称:meshwork,代码行数:42,代码来源:ZoomableCairoArea.cs

示例11: RoundedRectangle

 public static void RoundedRectangle (Context cr,
                                      Gdk.Rectangle area,
                                      int radius,
                                      Corners corners)
 {
     // Top Line
     cr.MoveTo (area.X + radius + m_Offset, area.Y + m_Offset);
     cr.LineTo (area.X + area.Width - radius - m_Offset,
                area.Y + m_Offset);
     
     // Top Right Corner
     if ((corners & Corners.TopRight) > 0) {
         cr.CurveTo (area.X + area.Width - radius - m_Offset,
                     area.Y + m_Offset,
                     area.X + area.Width,
                     area.Y,
                     area.X + area.Width - m_Offset,
                     area.Y + radius + m_Offset);
     }
     else {
         cr.LineTo (area.X + area.Width - m_Offset,
                    area.Y + m_Offset);
         cr.LineTo (area.X + area.Width - m_Offset,
                    area.Y + m_Offset + radius);
     }
     
     // Right Line
     cr.LineTo (area.X + area.Width - m_Offset,
                area.Y + area.Height - radius - m_Offset);
     
     // Bottom Right Corner
     if ((corners & Corners.BottomRight) > 0) {
         cr.CurveTo (area.X + area.Width - m_Offset,
                     area.Y + area.Height - m_Offset - radius,
                     area.X + area.Width,
                     area.Y + area.Height,
                     area.X + area.Width - m_Offset - radius,
                     area.Y + area.Height - m_Offset);
     }
     else {
         cr.LineTo (area.X + area.Width - m_Offset,
                    area.Y + area.Height - m_Offset);
         cr.LineTo (area.X + area.Width - m_Offset - radius,
                    area.Y + area.Height - m_Offset);
     }
     
     // Bottom Line
     cr.LineTo (area.X + m_Offset + radius,
                area.Y + area.Height - m_Offset);
     
     // Bottom Left Corner
     if ((corners & Corners.BottomLeft) > 0) {
         cr.CurveTo (area.X + m_Offset + radius,
                     area.Y + area.Height - m_Offset,
                     area.X,
                     area.Y + area.Height,
                     area.X + m_Offset,
                     area.Y + area.Height - m_Offset - radius);
     }
     else {
         cr.LineTo (area.X + m_Offset,
                    area.Y + area.Height - m_Offset);
         cr.LineTo (area.X + m_Offset,
                    area.Y + area.Height - m_Offset - radius);
     }
     
     // Left Line
     cr.LineTo (area.X + m_Offset,
                area.Y + m_Offset + radius);
     
     // Top Left Corner
     if ((corners & Corners.TopLeft) > 0) {
         cr.CurveTo (area.X + m_Offset,
                     area.Y + m_Offset + radius,
                     area.X,
                     area.Y,
                     area.X + m_Offset + radius,
                     area.Y + m_Offset);
     }
     else {
         cr.LineTo (area.X + m_Offset, area.Y + m_Offset);
         cr.LineTo (area.X + m_Offset + radius, area.Y + m_Offset);
     }
 }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:84,代码来源:Crumbs.cs


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