當前位置: 首頁>>代碼示例>>C#>>正文


C# CGContext.DrawLinearGradient方法代碼示例

本文整理匯總了C#中MonoMac.CoreGraphics.CGContext.DrawLinearGradient方法的典型用法代碼示例。如果您正苦於以下問題:C# CGContext.DrawLinearGradient方法的具體用法?C# CGContext.DrawLinearGradient怎麽用?C# CGContext.DrawLinearGradient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MonoMac.CoreGraphics.CGContext的用法示例。


在下文中一共展示了CGContext.DrawLinearGradient方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Draw

		internal static void Draw (CGContext ctx, GradientInfo gradient)
		{
			ctx.SaveState ();
			ctx.Clip ();
			using (var cg = new CGGradient (Util.DeviceRGBColorSpace, gradient.Colors.ToArray (), gradient.Stops.ToArray ())) {
				if (gradient.Linear)
					ctx.DrawLinearGradient (cg, gradient.Start, gradient.End, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
				else
					ctx.DrawRadialGradient (cg, gradient.Start, gradient.StartRadius, gradient.End, gradient.EndRadius, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
			}
			ctx.RestoreState ();
		}
開發者ID:m13253,項目名稱:xwt,代碼行數:12,代碼來源:GradientBackendHandler.cs

示例2: FillGradient

 public static void FillGradient(CGContext context, RectangleF rect, CGColor color1, CGColor color2, bool isHorizontal)
 {
     CGGradient gradientBackground;
     CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();
     
     float[] locationListBackground = new float[] { 1.0f, 0.0f };
     List<float> colorListBackground = new List<float>();
     colorListBackground.AddRange(color1.Components);
     colorListBackground.AddRange(color2.Components);
     gradientBackground = new CGGradient(colorSpace, colorListBackground.ToArray(), locationListBackground);
     
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     //context.ScaleCTM(1, -1);
     if(isHorizontal)
         context.DrawLinearGradient(gradientBackground, new PointF(rect.X, rect.Y), new PointF(rect.X + rect.Width, rect.Y + rect.Height), CGGradientDrawingOptions.DrawsBeforeStartLocation);
     else
         context.DrawLinearGradient(gradientBackground, new PointF(0, 0), new PointF(0, rect.Height), CGGradientDrawingOptions.DrawsBeforeStartLocation);
     context.RestoreState();
 }       
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:21,代碼來源:CoreGraphicsHelper.cs

示例3: DrawPattern

			void DrawPattern (CGContext context)
			{
				var start = new sd.PointF(0, 0);
				var end = start + sectionSize;

				context.ClipToRect(sd.RectangleF.Inflate (new sd.RectangleF(start, tileSize), 4, 4));

				if (Wrap == GradientWrapMode.Reflect) {
					for (int i = 0; i < 2; i ++) {
						context.DrawLinearGradient (Gradient, start, end, 0);
						context.DrawLinearGradient (InverseGradient, end, end + sectionSize, 0);
						start = start + sectionSize + sectionSize;
						end = end + sectionSize + sectionSize;
					}
				}
				else {
					for (int i = 0; i < 2; i ++) {
						context.DrawLinearGradient (Gradient, start, end, 0);
						start = start + sectionSize;
						end = end + sectionSize;
					}
				}
			}
開發者ID:JohnACarruthers,項目名稱:Eto,代碼行數:23,代碼來源:LinearGradientBrushHandler.cs


注:本文中的MonoMac.CoreGraphics.CGContext.DrawLinearGradient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。