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


C# CoreGraphics.CGContext类代码示例

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


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

示例1: RenderGlyphToContext

		public static void RenderGlyphToContext (CGContext context, PointF position, Glyph g, Fnt font, byte[] palette, int offset)
		{
			byte[] buf = new byte[g.Width * g.Height * 4];
			int i = 0;

			for (int y = g.Height - 1; y >= 0; y--) {
				for (int x = g.Width - 1; x >= 0; x--) {
					if (g.Bitmap[y,x] == 0)
						buf [i + 0] = 0;
					else if (g.Bitmap[y,x] == 1)
						buf [i + 0] = 255;
					else
						buf [i + 0] = 128;

					buf[i + 1] = palette[ (g.Bitmap[y,x]) * 3 + offset + 0];
					buf[i + 2] = palette[ (g.Bitmap[y,x]) * 3 + offset + 1];
					buf[i + 3] = palette[ (g.Bitmap[y,x]) * 3 + offset + 2];

					if (buf[i+1] == 252 && buf[i+2] == 0 && buf[i+3] == 252)
						buf[i + 0] = 0;

					i += 4;
				}
			}

			CGImage glyphImage = CreateImage (buf, (ushort)g.Width, (ushort)g.Height, 32, g.Width * 4);
			
			context.DrawImage (new RectangleF (position, new SizeF (g.Width, g.Height)), glyphImage);
		}
开发者ID:carriercomm,项目名称:scsharp,代码行数:29,代码来源:GuiUtil.cs

示例2: Graphics

 public Graphics(CGContext context, bool flipped = true)
 {
     if (context == null)
         throw new ArgumentNullException ("context");
     isFlipped = flipped;
     InitializeContext(context);
 }
开发者ID:stnk3000,项目名称:sysdrawing-coregraphics,代码行数:7,代码来源:Graphics.cs

示例3: CocoaGraphDrawer

 public CocoaGraphDrawer(CGContext g, int w, int h)
 {
     this.g = g;
     this.w = w;
     this.h = h;
     g.SetAllowsAntialiasing(true);
     g.InterpolationQuality = CGInterpolationQuality.High;
 }
开发者ID:ivynetca,项目名称:lapsestudio,代码行数:8,代码来源:CocoaGraphDrawer.cs

示例4: DrawInContext

		public override void DrawInContext (CGContext context)
		{
			base.DrawInContext (context);
			
			context.AddEllipseInRect (Bounds);
			context.SetFillColor (ClockColor);
			context.FillPath ();
		}
开发者ID:Anomalous-Software,项目名称:monomac,代码行数:8,代码来源:ClockLayer.cs

示例5: FillEllipsis

 public static void FillEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetFillColor(color);
     context.AddEllipseInRect(rect);
     context.FillPath();
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:8,代码来源:CoreGraphicsHelper.cs

示例6: GraphicsContextWrapper

 public GraphicsContextWrapper(CGContext context, float boundsWidth, float boundsHeight, BasicRectangle dirtyRect)
 {
     Context = context;
     BoundsWidth = boundsWidth;
     BoundsHeight = boundsHeight;
     DirtyRect = dirtyRect;
     Density = GetDisplayScale();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:8,代码来源:GraphicsContextWrapper.cs

示例7: FillRect

 public static void FillRect(CGContext context, RectangleF rect, CGColor color)
 {
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     context.SetFillColor(color);
     context.FillRect(rect);
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs

示例8: DrawEllipsis

 public static void DrawEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetStrokeColor(color);
     context.SetLineWidth(lineWidth);
     context.AddEllipseInRect(rect);
     context.StrokePath();
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs

示例9: DrawRect

 public static void DrawRect(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     context.SetLineWidth(lineWidth);
     context.SetStrokeColor(color);
     context.StrokeRect(rect);
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:10,代码来源:CoreGraphicsHelper.cs

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

示例11: CoreGraphicsRenderContext

        /// <summary>
        /// Initializes a new instance of the <see cref="CoreGraphicsRenderContext"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        public CoreGraphicsRenderContext(CGContext context)
        {
            this.gctx = context;

            // Set rendering quality
            this.gctx.SetAllowsFontSmoothing (true);
            this.gctx.SetAllowsFontSubpixelQuantization (true);
            this.gctx.SetAllowsAntialiasing (true);
            this.gctx.SetShouldSmoothFonts (true);
            this.gctx.SetShouldAntialias (true);
            this.gctx.InterpolationQuality = CGInterpolationQuality.High;
            this.gctx.SetTextDrawingMode (CGTextDrawingMode.Fill);
            this.gctx.TextMatrix = CGAffineTransform.MakeScale (1, 1);
        }
开发者ID:trinnguyen,项目名称:oxyplot-xammac,代码行数:18,代码来源:CoreGraphicsRenderContext.cs

示例12: MeasureStringWidth

        public static float MeasureStringWidth(CGContext context, string text, string fontName, float fontSize)
        {
            if (string.IsNullOrEmpty(text))
                return 0;

            context.SaveState();
            PointF pos = context.TextPosition;
            context.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);
            context.TextMatrix = CGAffineTransform.MakeScale(1.0f, -1.0f);
            //context.TranslateCTM(0, 20);
            context.ScaleCTM(1, -1);
            context.SetTextDrawingMode(CGTextDrawingMode.Invisible);
            context.ShowTextAtPoint(pos.X, pos.Y, text);
            PointF pos2 = context.TextPosition;
            context.RestoreState();
            
            return pos2.X - pos.X;
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:18,代码来源:CoreGraphicsHelper.cs

示例13: DrawText

 public static void DrawText(CGContext context, string text, string fontName, float fontSize, float translateHeight, float x, float y)
 {
     context.SaveState();
     context.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);
     context.SetTextDrawingMode(CGTextDrawingMode.Fill);
     context.SetFillColor(new CGColor(1, 1));
     context.SetStrokeColor(new CGColor(1.0f, 1.0f));
     //context.AddRect(rectText);
     //context.Clip();
     context.TextMatrix = CGAffineTransform.MakeScale(1.0f, -1.0f);
     context.TranslateCTM(0, translateHeight);
     context.ScaleCTM(1, -1);
     context.ShowTextAtPoint(x, y, text);
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:15,代码来源:CoreGraphicsHelper.cs

示例14: DrawTextInRect

 public static void DrawTextInRect(CGContext context, RectangleF rect, string text, string fontName, float fontSize, NSColor fontColor)
 {
     context.SaveState();
     NSString str = new NSString(text);
     var dict = new NSMutableDictionary();
     dict.Add(NSAttributedString.ForegroundColorAttributeName, fontColor);
     dict.Add(NSAttributedString.FontAttributeName, NSFont.FromFontName(fontName, fontSize));
     str.DrawString(rect, dict);
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:10,代码来源:CoreGraphicsHelper.cs

示例15: MeasureText

 public static SizeF MeasureText(CGContext context, string text, string fontName, float fontSize)
 {
     NSString str = new NSString(text);
     var dict = new NSMutableDictionary();
     dict.Add(NSAttributedString.FontAttributeName, NSFont.FromFontName(fontName, fontSize));
     var size = str.StringSize(dict);
     return size;
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:8,代码来源:CoreGraphicsHelper.cs


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