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


C# CGContext.SetLineJoin方法代码示例

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


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

示例1: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing lines with a white stroke color
		context.SetRGBStrokeColor(1, 1, 1, 1);
		
		// Preserve the current drawing state
		context.SaveState();
		
		// Set the line width so that the cap is visible
		context.SetLineWidth(20);
		
		// Line caps demonstration
		
		// Line cap butt, default.
		context.SetLineCap(CGLineCap.Butt);
		context.MoveTo(40, 30);
		context.AddLineToPoint(280, 30);
		context.StrokePath();
		
		// Line cap round
		context.SetLineCap(CGLineCap.Round);
		context.MoveTo(40, 65);
		context.AddLineToPoint(280, 65);
		context.StrokePath();
		
		// Line cap square
		context.SetLineCap(CGLineCap.Square);
		context.MoveTo(40, 100);
		context.AddLineToPoint(280, 100);
		context.StrokePath();
		
		// Restore the previous drawing state, and save it again.
		context.RestoreState();
		context.SaveState();
		
		// Set the line width so that the join is visible
		context.SetLineWidth(20);
		
		// Line join miter, default
		context.SetLineJoin(CGLineJoin.Miter);
		context.MoveTo(40, 260);
		context.AddLineToPoint(160, 140);
		context.AddLineToPoint(280, 260);
		context.StrokePath();
		
		// Line join round
		context.SetLineJoin(CGLineJoin.Round);
		context.MoveTo(40, 320);
		context.AddLineToPoint(160, 200);
		context.AddLineToPoint(280, 320);
		context.StrokePath();
		
		// Line join bevel
		context.SetLineJoin(CGLineJoin.Bevel);
		context.MoveTo(40, 380);
		context.AddLineToPoint(160, 260);
		context.AddLineToPoint(280, 380);
		context.StrokePath();
	
		// Restore the previous drawing state.
		context.RestoreState();
	
		// Demonstrate where the path that generated each line is
		context.SetRGBStrokeColor(1, 0, 0, 1);
		context.SetLineWidth(3);
		context.MoveTo(40, 30);
		context.AddLineToPoint(280, 30);
		context.MoveTo(40, 65);
		context.AddLineToPoint(280, 65);
		context.MoveTo(40, 100);
		context.AddLineToPoint(280, 100);
		context.MoveTo(40, 260);
		context.AddLineToPoint(160, 140);
		context.AddLineToPoint(280, 260);
		context.MoveTo(40, 320);
		context.AddLineToPoint(160, 200);
		context.AddLineToPoint(280, 320);
		context.MoveTo(40, 380);
		context.AddLineToPoint(160, 260);
		context.AddLineToPoint(280, 380);
		context.StrokePath();
	}	
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:82,代码来源:LineDrawing.cs

示例2: DrawRoundedLine

        public static void DrawRoundedLine(CGContext context, List<PointF> points, CGColor color, float lineWidth, bool closePath, bool dashed)
        {
            if (points == null)
                throw new NullReferenceException();

            if (points.Count == 0)
                throw new ArgumentException("The line must have at least one point.");

            context.SaveState();
            context.SetStrokeColor(color);
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Round);
            context.SetLineJoin(CGLineJoin.Round);
            context.MoveTo(points[0].X, points[0].Y);
            for(int a = 1; a < points.Count; a++)
                context.AddLineToPoint(points[a].X, points[a].Y);
            if (dashed)
                context.SetLineDash(0, new float[2] { 1, 2 }, 2);
            if (closePath)
                context.ClosePath();
            context.StrokePath();
            context.RestoreState();
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:23,代码来源:CoreGraphicsHelper.cs

示例3: DrawRectangle

        private void DrawRectangle(CGContext g, PinboardData.RectangleInfo rectInfo)
        {
            g.SetFillColor(rectInfo.Color);
            g.FillRect(rectInfo.Rectangle);

            float pw = 0.5f;
            CGColor rectBorderColor = new CGColor(0f, rectInfo.Color.Alpha);

            g.SetLineWidth(pw);
            g.SetStrokeColor(rectBorderColor);
            g.SetFillColor(rectInfo.Color);
            g.SetLineJoin(CGLineJoin.Miter);
            g.BeginPath();
            g.StrokeRect(rectInfo.Rectangle);

            int margin = 5;
            // TODO: Make the font configurable
            NSFont font = NSFont.FromFontName("Helvetica", 12f);
            NSObject[] objects = new NSObject[] { font, (NSNumber)0 };
            NSObject[] keys = new NSObject[] { NSAttributedString.FontAttributeName, NSAttributedString.LigatureAttributeName };
            NSDictionary attributes = NSDictionary.FromObjectsAndKeys(objects, keys);
            NSAttributedString attrString = new NSAttributedString(rectInfo.Name, attributes);

            attrString.DrawString(new RectangleF(rectInfo.X + margin, rectInfo.Y + margin, rectInfo.Width - 2 * margin, rectInfo.Height - 2 * margin));
        }
开发者ID:jlyonsmith,项目名称:Pinboard,代码行数:25,代码来源:PinboardView.cs

示例4: DrawPoints

        //does the actual coloring
        void DrawPoints(CGContext dctx)
        {
            var swatches = Swatches;
            var swatchslider = swatchSlider;

            dctx.BeginPath ();
            dctx.MoveTo (Points.First().X, Points.First().Y);
            dctx.SetLineWidth (swatchslider.Value);
            dctx.SetBlendMode (CGBlendMode.Normal);

            foreach (var crayon in Crayons) {
                if(crayon.Selected) {
                    if (crayon.Name == "Eraser") {
                        dctx.SetBlendMode (CGBlendMode.Clear);
                        dctx.SetStrokeColor (UIColor.Clear.CGColor);
                    } else {
                        dctx.SetBlendMode (CGBlendMode.Normal);
                        var swatchImg = colorSwatch (swatches[0], crayon.R / 255f, crayon.G / 255f, crayon.B / 255f, 1f);

                        UIColor pattern = UIColor.FromPatternImage(swatchImg);
                        dctx.SetStrokeColor(pattern.CGColor);
                    }
                    dctx.SetLineCap (CGLineCap.Round);
                    dctx.SetLineJoin (CGLineJoin.Round);
                }
            }
            //set fill color with current crayons
            foreach (var point in Points) {
                dctx.AddLineToPoint(point.X, point.Y);
            }
            dctx.StrokePath();
        }
开发者ID:chkn,项目名称:CrayonCamelot,代码行数:33,代码来源:Canvas.cs


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