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


C# CGContext.SetLineCap方法代码示例

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


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

示例1: CoreGraphicsGraphics

		public CoreGraphicsGraphics (CGContext c, bool highQuality)
		{
			if (c == null) throw new ArgumentNullException ("c");

			_c = c;
			//_highQuality = highQuality;

			if (highQuality) {
				c.SetLineCap (CGLineCap.Round);
			}
			else {
				c.SetLineCap (CGLineCap.Butt);
			}

			SetColor (Colors.Black);
		}
开发者ID:praeclarum,项目名称:Praeclarum,代码行数:16,代码来源:CoreGraphicsGraphics.cs

示例2: HatchDiagonalCross

        void HatchDiagonalCross(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, true);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchHeight / 2.0f;

            context.MoveTo(0, 0);
            context.AddLineToPoint(hatchWidth, hatchHeight);
            context.StrokePath();

            context.MoveTo(hatchWidth, 0);
            context.AddLineToPoint(0, hatchHeight);
            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:26,代码来源:HatchBrush.cs

示例3: HatchDiagonalBrick

        void HatchDiagonalBrick(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            hatchHeight -= 1;
            hatchWidth -= 1;

            context.MoveTo(0, 0);
            context.AddLineToPoint(hatchWidth,hatchHeight);
            context.StrokePath();

            context.MoveTo(0, hatchHeight);
            context.AddLineToPoint(hatchWidth / 2.0f,hatchHeight / 2.0f);
            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:27,代码来源:HatchBrush.cs

示例4: HatchDashedHorizontal

        void HatchDashedHorizontal(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchHeight / 2.0f - 1;
            hatchWidth -=1;
            hatchHeight -= 1;

            context.MoveTo(halfMe+1, halfMe);
            context.AddLineToPoint(hatchWidth, halfMe);
            context.StrokePath();

            context.MoveTo(0,hatchHeight);
            context.AddLineToPoint(halfMe, hatchHeight);
            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:28,代码来源:HatchBrush.cs

示例5: HatchVertical

        protected void HatchVertical(CGContext context)
        {
            var hatchSize = getHatchWidth (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchSize, false);

            /* draw background */
            drawBackground (context, backColor, hatchSize, hatchSize);

            /* draw horizontal line in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchSize / 2.0f;

            // draw a horizontal line
            context.MoveTo(0, 0);
            context.AddLineToPoint(0, hatchSize);

            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:23,代码来源:HatchBrush.cs

示例6: HatchUpwardDiagonal

        protected void HatchUpwardDiagonal(CGContext context)
        {
            var hatchSize = getHatchWidth (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            if (hatchStyle != HatchStyle.ForwardDiagonal &&
                hatchStyle != HatchStyle.BackwardDiagonal)
            {
                initializeContext(context, hatchSize, false);
            }
            else {
                initializeContext(context, hatchSize, true);
            }

            /* draw background */
            drawBackground (context, backColor, hatchSize, hatchSize);

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetFillColor(foreColor.ToCGColor());

            context.SetLineWidth(1);
            context.SetLineCap(CGLineCap.Square);

            context.MoveTo(0,0);
            context.AddLineToPoint(hatchSize,hatchSize);
            /* draw a diagonal line for as many times as linewidth*/
            for (int l = 0; l < lineWidth; l++)
            {
                /* draw a diagonal line */
                context.MoveTo(l,0);
                context.AddLineToPoint(hatchSize, hatchSize-l);

                context.StrokePath();
            }

            /**
             * because we are within a rectangular pattern we have to complete the tip of the preceeding line
             * pattern
             */
            for (int k = 1; k < lineWidth; k++)
            {
                /* draw a diagonal line */
                context.MoveTo(0,hatchSize-k);
                context.AddLineToPoint(k-1, hatchSize-1);

                context.StrokePath();
            }
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:49,代码来源:HatchBrush.cs

示例7: 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

示例8: 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

示例9: HatchWeave

        void HatchWeave(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfWidth = hatchWidth / 2.0f;
            float halfHeight = hatchHeight / 2.0f;

            CGRect rect = new CGRect (0,0,1,1);

            // Add upward diagonals
            context.MoveTo(0,0);
            context.AddLineToPoint(halfWidth, halfHeight);
            context.StrokePath();

            context.MoveTo(0, halfHeight);
            context.AddLineToPoint(halfWidth -1, hatchHeight - 1);
            context.StrokePath();

            context.MoveTo(halfWidth, 0);
            context.AddLineToPoint(6, 2);
            context.StrokePath();

            //			context.MoveTo(0, 4);
            //			context.AddLineToPoint(2, 2);
            //			context.StrokePath();

            context.MoveTo(2,6);
            context.AddLineToPoint(7, 1);
            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:45,代码来源:HatchBrush.cs

示例10: HatchSolidDiamond

        void HatchSolidDiamond(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchWidth / 2.0f;

            // We will paint two triangles from corners meeting in the middle
            // make sure to offset by half pixels so that the point is actually a point.
            context.MoveTo(-HALF_PIXEL_X,HALF_PIXEL_Y);
            context.AddLineToPoint(2+HALF_PIXEL_X, halfMe - HALF_PIXEL_Y);
            context.AddLineToPoint(-HALF_PIXEL_X, hatchHeight- (1.0f + HALF_PIXEL_Y));
            context.ClosePath();
            context.FillPath();

            // now we do the right one
            context.MoveTo(hatchWidth,HALF_PIXEL_Y);
            context.AddLineToPoint(halfMe+HALF_PIXEL_X, halfMe - HALF_PIXEL_Y);
            context.AddLineToPoint(hatchWidth, hatchHeight - (1.0f + HALF_PIXEL_Y));
            context.ClosePath();
            context.FillPath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:34,代码来源:HatchBrush.cs

示例11: HatchShingle

        void HatchShingle(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchWidth / 2.0f;

            // We are basically going to draw a lamda sign

            // Draw base
            context.MoveTo(0,0);
            context.AddLineToPoint(halfMe,halfMe-HALF_PIXEL_Y);
            context.AddLineToPoint(hatchWidth, HALF_PIXEL_Y);
            context.StrokePath();

            // draw the first part of tail
            context.MoveTo(halfMe + HALF_PIXEL_X, halfMe);
            context.AddLineToPoint(halfMe + HALF_PIXEL_X, halfMe + 1);
            context.StrokePath();

            // now the last curl on the tail
            CGRect rect = new CGRect (1,hatchHeight-1,1,1);
            setPixels(context, rect);

            rect.X += 1;
            setPixels(context, rect);

            rect.X += 1;
            rect.Y -= 1;
            setPixels(context, rect);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:43,代码来源:HatchBrush.cs

示例12: HatchPlaid

        void HatchPlaid(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchWidth / 2.0f;
            CGRect rect = new CGRect (0,0,1,1);

            // fraw the alternating pattern for half of area
            int x = 0;
            int y = 0;

            for (y = 0; y<halfMe; y+=2)
            {
                for (x = 1; x < hatchWidth; x+=2)
                {
                    rect.X = x;
                    rect.Y = y;
                    setPixels(context, rect);
                }
            }
            for (y = 1; y<halfMe; y+=2)
            {
                for (x = 0; x < hatchWidth; x+=2)
                {
                    rect.X = x;
                    rect.Y = y;
                    setPixels(context, rect);
                }
            }

            // draw a square
            rect.X = 0;
            rect.Y = halfMe;
            rect.Width = halfMe;
            rect.Height = halfMe;
            setPixels(context, rect);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:50,代码来源:HatchBrush.cs

示例13: HatchOutlinedDiamond

        void HatchOutlinedDiamond(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            // this is really just two diagonal lines from each corner too
            // their opposite corners.
            context.MoveTo(0,0);
            context.AddLineToPoint(hatchWidth, hatchHeight);
            context.StrokePath();
            context.MoveTo(1,hatchHeight);
            context.AddLineToPoint(hatchWidth, 1);
            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:26,代码来源:HatchBrush.cs

示例14: HatchHorizontalBrick

        void HatchHorizontalBrick(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            CGRect rect = new CGRect (0,0,1,1);

            rect.Y = 3;
            rect.Width = hatchWidth;
            rect.Height = hatchHeight - 4;
            context.StrokeRect(rect);

            context.MoveTo(hatchWidth / 2.0f, 0);
            context.AddLineToPoint(hatchWidth / 2.0f,3);
            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:30,代码来源:HatchBrush.cs

示例15: 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


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