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


C# CGContext.SetRGBFillColor方法代码示例

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


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

示例1: DrawStars

        protected void DrawStars(CGContext context)
        {
            context.SetRGBFillColor (1f, 0f, 0f, 1f);

            // save state so that as we translate (move the origin around,
            // it goes back to normal when we restore)
            context.SetRGBFillColor (0f, 0f, 0.329f, 1.0f);
            context.SaveState ();
            context.TranslateCTM (30, 300);
            DrawStar (context, 30);
            context.RestoreState ();

            context.SetRGBFillColor (1f, 0f, 0f, 1f);
            context.SaveState ();
            context.TranslateCTM (120, 200);
            DrawStar (context, 30);
            context.RestoreState ();
        }
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:18,代码来源:CameraOverlayView.cs

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

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

		public void DrawTextWithUTF8Fonts (CGContext mBmpContext, string text, float x, float y, string font_family, double text_size)
		{
			/*
			The problem is that CoreGraphics APIs for CGContext do not support rendering UTF8 code, and then ShowTextAtPoint() is limited to the text encoding in MacRoman.
			The fix is to use the UIKit function DrawString() instead.
			 */

			UIGraphics.PushContext (mBmpContext);
			mBmpContext.SetRGBFillColor(1f,1f,1f,1f);

			UIFont tfont = UIFont.FromName (font_family,(float)text_size);

			NSString nsstr = new NSString(text);
			SizeF sz = nsstr.StringSize(tfont);
			RectangleF rect = new RectangleF(x,y,sz.Width,sz.Height);
			nsstr.DrawString( rect, tfont);


			UIGraphics.PopContext ();
		}
开发者ID:acremean,项目名称:OxyPlot.2DGraphLib.MonoTouch,代码行数:20,代码来源:MonoTouchRenderContext.cs

示例5: DrawLayer

			public override void DrawLayer (CALayer layer, CGContext context)
			{
				context.SaveState ();
				context.SetRGBFillColor (1.0f, 1.0f, 1.0f, 1.0f);
				context.FillRect (context.GetClipBoundingBox ());
				context.TranslateCTM (0.0f, layer.Bounds.Size.Height);
				context.ScaleCTM (1.0f, -1.0f);
				context.ConcatCTM (ParentController.PdfPage.GetDrawingTransform (CGPDFBox.Crop, layer.Bounds, 0, true));
				context.DrawPDFPage (ParentController.PdfPage);
				context.RestoreState ();
			}
开发者ID:21Off,项目名称:21Off,代码行数:11,代码来源:PdfViewController.cs

示例6: DrawStarPattern

		// This is a slightly more complicated draw pattern, but using it is just 
		// as easy as the previous one. To use this one, simply change "DrawPolkaDotPattern"
		// in line 54 above to "DrawStarPattern"
		protected void DrawStarPattern (CGContext context)
		{
			// declare vars
			float starDiameter = 16;
			// 144º
			float theta = 2 * (float)Math.PI * (2f / 5f);
			float radius = starDiameter / 2;
			
			// move up and over
			context.TranslateCTM (starDiameter / 2, starDiameter / 2);
			
			context.MoveTo (0, radius);
			for (int i = 1; i < 5; i++) {
				context.AddLineToPoint (radius * (float)Math.Sin (i * theta), radius * (float)Math.Cos (i * theta));
			}
			// fill our star as dark gray
			context.SetRGBFillColor (.3f, .3f, .3f, 1);
			context.ClosePath ();
			context.FillPath ();
		}
开发者ID:robertgreen,项目名称:monotouch-samples,代码行数:23,代码来源:Controller.cs

示例7: DrawPolkaDotPattern

		// This is our pattern callback. it's called by coregraphics to create 
		// the pattern base.
		protected void DrawPolkaDotPattern (CGContext context)
		{
			context.SetRGBFillColor (.3f, .3f, .3f, 1);
			context.FillEllipseInRect (new RectangleF (4, 4, 8, 8));
		}
开发者ID:robertgreen,项目名称:monotouch-samples,代码行数:7,代码来源:Controller.cs

示例8: DrawColored

    static void DrawColored(CGContext context)
    {
        // Dark Blue
        context.SetRGBFillColor(29 / 255f, 156 / 255f, 215 / 255f, 10);
        context.FillRect(new RectangleF(0, 0, 8, 8));
        context.FillRect(new RectangleF(8, 8, 8, 8));

        // Light Blue
        context.SetRGBFillColor(204 / 255f, 224 / 255f, 244 / 255f, 10);
        context.FillRect(new RectangleF(8, 0, 8, 8));
        context.FillRect(new RectangleF(0, 8, 8, 8));
    }
开发者ID:CVertex,项目名称:monotouch-samples,代码行数:12,代码来源:rendereddrawing.cs

示例9: DrawFlag

		protected void DrawFlag (CGContext context)
		{
			// declare vars
			int i, j;
			
			// general sizes
			float flagWidth = Frame.Width * .8f;
			float flagHeight = (float)(flagWidth / 1.9);
			PointF flagOrigin = new PointF (Frame.Width * .1f, Frame.Height / 3);
			
			// stripe
			float stripeHeight = flagHeight / 13;
			float stripeSpacing = stripeHeight * 2;
			RectangleF stripeRect = new RectangleF (0, 0, flagWidth, stripeHeight);
			
			// star field
			float starFieldHeight = 7 * stripeHeight;
			float starFieldWidth = flagWidth * (2f / 5f);
			RectangleF starField = new RectangleF (flagOrigin.X, flagOrigin.Y + (6 * stripeHeight), starFieldWidth, starFieldHeight);
			
			// stars
			float starDiameter = flagHeight * 0.0616f;
			float starHorizontalCenterSpacing = (starFieldWidth / 6);
			float starHorizontalPadding = (starHorizontalCenterSpacing / 4);
			float starVerticalCenterSpacing = (starFieldHeight / 5);
			float starVerticalPadding = (starVerticalCenterSpacing / 4);
			PointF firstStarOrigin = new PointF (flagOrigin.X + starHorizontalPadding, flagOrigin.Y + flagHeight - starVerticalPadding - (starVerticalCenterSpacing / 2));
			PointF secondRowFirstStarOrigin = new PointF (firstStarOrigin.X + (starHorizontalCenterSpacing / 2), firstStarOrigin.Y - (starVerticalCenterSpacing / 2));
			
			// white background + shadow
			context.SaveState ();
			// note: when drawing on-screen,the coord space for shadows doesn't get modified
			context.SetShadow (new SizeF (15, 15), 7);
			context.SetRGBFillColor (1, 1, 1, 1);
			context.FillRect (new RectangleF (flagOrigin.X, flagOrigin.Y, flagWidth, flagHeight));
			context.RestoreState ();
			
			// create a stripe layer
			using (CGLayer stripeLayer = CGLayer.Create (context, stripeRect.Size)) {
				
				// set red as the fill color
				// this works
				stripeLayer.Context.SetRGBFillColor (1f, 0f, 0f, 1f);
				// but this doesn't ????
				//stripeLayer.Context.SetFillColor (new float[] { 1f, 0f, 0f, 1f });
				// fill the stripe
				stripeLayer.Context.FillRect (stripeRect);
				
				// loop through the stripes and draw the layer
				context.SaveState ();
				for (i = 0; i < 7; i++) {
					Console.WriteLine ("drawing stripe layer");
					// draw the layer
					context.DrawLayer (stripeLayer, flagOrigin);
					// move the origin
					context.TranslateCTM (0, stripeSpacing);
				}
				context.RestoreState ();
			}
			
			// draw the star field
			//BUGBUG: apple bug - this only works on on-screen CGContext and CGLayer
			//context.SetFillColor (new float[] { 0f, 0f, 0.329f, 1.0f });
			context.SetRGBFillColor (0f, 0f, 0.329f, 1.0f);
			context.FillRect (starField);
			
			// create the star layer
			using (CGLayer starLayer = CGLayer.Create (context, starField.Size)) {
				
				// draw the stars
				DrawStar (starLayer.Context, starDiameter);
				
				// 6-star rows
				// save state so that as we translate (move the origin around, 
				// it goes back to normal when we restore)
				context.SaveState ();
				context.TranslateCTM (firstStarOrigin.X, firstStarOrigin.Y);
				// loop through each row
				for (j = 0; j < 5; j++) {
					
					// each star in the row
					for (i = 0; i < 6; i++) {
						
						// draw the star, then move the origin to the right
						context.DrawLayer (starLayer, new PointF (0f, 0f));
						context.TranslateCTM (starHorizontalCenterSpacing, 0f);
					}
					// move the row down, and then back left
					context.TranslateCTM ((-i * starHorizontalCenterSpacing), -starVerticalCenterSpacing);
				}
				context.RestoreState ();
				
				// 5-star rows			
				context.SaveState ();
				context.TranslateCTM (secondRowFirstStarOrigin.X, secondRowFirstStarOrigin.Y);
				// loop through each row
				for (j = 0; j < 4; j++) {
					
					// each star in the row
					for (i = 0; i < 5; i++) {
//.........这里部分代码省略.........
开发者ID:rojepp,项目名称:monotouch-samples,代码行数:101,代码来源:View.cs


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