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


C# CGContext.SetRGBStrokeColor方法代码示例

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


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

示例1: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetRGBStrokeColor (1, 1, 1, 1);
		// And drawing with a blue fill color
		context.SetRGBFillColor (0, 0, 1, 1);
		// Draw them with a 2 stroke width so they are a bit more visible.
		context.SetLineWidth (2);
		
		// Add Rect to the current path, then stroke it
		context.AddRect (new RectangleF (30, 30, 60, 60));
		context.StrokePath ();
		
		// Stroke Rect convenience that is equivalent to above
		context.StrokeRect (new RectangleF (30, 120, 60, 60));
		
		// Stroke rect convenience equivalent to the above, plus a call to context.SetLineWidth ().
		context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 10);
		// Demonstate the stroke is on both sides of the path.
		context.SaveState ();
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 2);
		context.RestoreState ();
		
		var rects = new RectangleF []
		{
			new RectangleF (120, 30, 60, 60),
			new RectangleF (120, 120, 60, 60),
			new RectangleF (120, 210, 60, 60),
		};
		// Bulk call to add rects to the current path.
		context.AddRects (rects);
		context.StrokePath ();
		
		// Create filled rectangles via two different paths.
		// Add/Fill path
		context.AddRect (new RectangleF (210, 30, 60, 60));
		context.FillPath ();
		// Fill convienience.
		context.FillRect (new RectangleF (210, 120, 60, 60));
	}	
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:41,代码来源:PolyDrawing.cs

示例2: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		context.SetRGBStrokeColor (1, 1, 1, 1f);
		
		// Draw lines with a stroke width from 1-10
		for (int i = 1; i <= 10; ++i) {
			context.SetLineWidth (i);
			context.MoveTo (10, (float) i * 20.5f);
			context.AddLineToPoint (310, (float)i * 20.5f);
			context.StrokePath ();
		}
		
		// Demonstration that stroke is even on both sides of the line
		context.SetLineWidth(15);
		context.MoveTo (10, 245.5f);
		context.AddLineToPoint (310, 245.5f);
		context.StrokePath ();
	
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.SetLineWidth (3);
		context.MoveTo (10, 245.5f);
		context.AddLineToPoint (310, 245.5f);
		context.StrokePath ();
	}	
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:24,代码来源:LineDrawing.cs

示例3: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		var imageRect = new RectangleF (8, 8, 64, 64);
		
		// Note: The images are actually drawn upside down because Quartz image drawing expects
		// the coordinate system to have the origin in the lower-left corner, but a UIView
		// puts the origin in the upper-left corner. For the sake of brevity (and because
		// it likely would go unnoticed for the image used) this is not addressed here.
		// For the demonstration of PDF drawing however, it is addressed, as it would definately
		// be noticed, and one method of addressing it is shown there.
	
		// Draw the image in the upper left corner (0,0) with size 64x64
		context.DrawImage (imageRect, image);
		
		// Tile the same image across the bottom of the view
		// CGContextDrawTiledImage() will fill the entire clipping area with the image, so to avoid
		// filling the entire view, we'll clip the view to the rect below. This rect extends
		// past the region of the view, but since the view's rectangle has already been applied as a clip
		// to our drawing area, it will be intersected with this rect to form the final clipping area
		context.ClipToRect(new RectangleF (0, 80, Bounds.Width, Bounds.Height));
		
		// The origin of the image rect works similarly to the phase parameter for SetLineDash and
		// SetPatternPhase and specifies where in the coordinate system the "first" image is drawn.
		// The size (previously set to 64x64) specifies the size the image is scaled to before being tiled.
		imageRect.X = 32;
		imageRect.Y = 112;
		context.DrawTiledImage (imageRect, image);
		
		// Highlight the "first" image from the DrawTiledImage call.
		context.SetRGBFillColor (1, 0, 0, 0.5f);
		context.FillRect (imageRect);
		
		// And stroke the clipped area
		context.SetLineWidth (3);
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.StrokeRect (context.GetClipBoundingBox ());
	}
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:37,代码来源:ImageDrawing.cs

示例4: DrawInContext


//.........这里部分代码省略.........
            new RectangleF(170, 280, 120, 120),
        };

        // Linear Gradients
        PointF start, end;

        // Clip to area to draw the gradient, and draw it. Since we are clipping, we save the graphics state
        // so that we can revert to the previous larger area.
        context.SaveState();
        context.ClipToRect(clips[0]);

        // A linear gradient requires only a starting & ending point.
        // The colors of the gradient are linearly interpolated along the line segment connecting these two points
        // A gradient location of 0 means that color is expressed fully at the 'start' point
        // a location of 1 means that color is expressed fully at the 'end' point.
        // The gradient fills outwards perpendicular to the line segment connectiong start & end points
        // (which is why we need to clip the context, or the gradient would fill beyond where we want it to).
        // The gradient options (last) parameter determines what how to fill the clip area that is "before" and "after"
        // the line segment connecting start & end.
        start = demoLGStart(clips[0]);
        end = demoLGEnd(clips[0]);
        context.DrawLinearGradient(gradient, start, end, 0);
        context.RestoreState();

        // Same as above for each combination of CGGradientDrawingOptions.DrawsBeforeStartLocation & CGGradientDrawingOptions.DrawsAfterEndLocation

        context.SaveState();
        context.ClipToRect(clips[1]);
        start = demoLGStart(clips[1]);
        end = demoLGEnd(clips[1]);
        context.DrawLinearGradient(gradient, start, end, CGGradientDrawingOptions.DrawsBeforeStartLocation);
        context.RestoreState();

        context.SaveState();
        context.ClipToRect(clips[2]);
        start = demoLGStart(clips[2]);
        end = demoLGEnd(clips[2]);
        context.DrawLinearGradient(gradient, start, end, CGGradientDrawingOptions.DrawsAfterEndLocation);
        context.RestoreState();

        context.SaveState();
        context.ClipToRect(clips[3]);
        start = demoLGStart(clips[3]);
        end = demoLGEnd(clips[3]);
        context.DrawLinearGradient(gradient, start, end, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
        context.RestoreState();

        // Radial Gradients

        float startRadius, endRadius;

        // Clip to area to draw the gradient, and draw it. Since we are clipping, we save the graphics state
        // so that we can revert to the previous larger area.
        context.SaveState();
        context.ClipToRect(clips[4]);

        // A radial gradient requires a start & end point as well as a start & end radius.
        // Logically a radial gradient is created by linearly interpolating the center, radius and color of each
        // circle using the start and end point for the center, start and end radius for the radius, and the color ramp
        // inherant to the gradient to create a set of stroked circles that fill the area completely.
        // The gradient options specify if this interpolation continues past the start or end points as it does with
        // linear gradients.
        start = end = demoRGCenter(clips[4]);
        startRadius = demoRGInnerRadius(clips[4]);
        endRadius = demoRGOuterRadius(clips[4]);
        context.DrawRadialGradient(gradient, start, startRadius, end, endRadius, 0);
        context.RestoreState();

        // Same as above for each combination of CGGradientDrawingOptions.DrawsBeforeStartLocation & CGGradientDrawingOptions.DrawsAfterEndLocation

        context.SaveState();
        context.ClipToRect(clips[5]);
        start = end = demoRGCenter(clips[5]);
        startRadius = demoRGInnerRadius(clips[5]);
        endRadius = demoRGOuterRadius(clips[5]);
        context.DrawRadialGradient(gradient, start, startRadius, end, endRadius, CGGradientDrawingOptions.DrawsBeforeStartLocation);
        context.RestoreState();

        context.SaveState();
        context.ClipToRect(clips[6]);
        start = end = demoRGCenter(clips[6]);
        startRadius = demoRGInnerRadius(clips[6]);
        endRadius = demoRGOuterRadius(clips[6]);
        context.DrawRadialGradient(gradient, start, startRadius, end, endRadius, CGGradientDrawingOptions.DrawsAfterEndLocation);
        context.RestoreState();

        context.SaveState();
        context.ClipToRect(clips[7]);
        start = end = demoRGCenter(clips[7]);
        startRadius = demoRGInnerRadius(clips[7]);
        endRadius = demoRGOuterRadius(clips[7]);
        context.DrawRadialGradient(gradient, start, startRadius, end, endRadius, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
        context.RestoreState();

        // Show the clipping areas
        context.SetLineWidth(2);
        context.SetRGBStrokeColor(1, 0, 0, 1);
        context.AddRects(clips);
        context.StrokePath();
    }
开发者ID:CVertex,项目名称:monotouch-samples,代码行数:101,代码来源:rendereddrawing.cs


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