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


C# Cairo类代码示例

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


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

示例1: OnMouseMove

        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            if (!is_drawing)
                return;

            double x = Utility.Clamp (point.X, 0, PintaCore.Workspace.ImageSize.X - 1);
            double y = Utility.Clamp (point.Y, 0, PintaCore.Workspace.ImageSize.Y - 1);

            PintaCore.Layers.ShowSelection = true;

            ImageSurface surf = PintaCore.Layers.ToolLayer.Surface;

            using (Context g = new Context (surf)) {
                g.Antialias = Antialias.Subpixel;

                if (path != null) {
                    g.AppendPath (path);
                    (path as IDisposable).Dispose ();
                }

                g.LineTo (x, y);

                path = g.CopyPath ();

                g.FillRule = FillRule.EvenOdd;
                g.ClosePath ();

                Path old = PintaCore.Layers.SelectionPath;

                PintaCore.Layers.SelectionPath = g.CopyPath ();
                (old as IDisposable).Dispose ();
            }

            PintaCore.Workspace.Invalidate ();
        }
开发者ID:xxgreg,项目名称:Pinta,代码行数:35,代码来源:LassoSelectTool.cs

示例2: AlphaBlend

 public static Cairo.Color AlphaBlend (Cairo.Color ca, Cairo.Color cb, double alpha)
 {
     return new Cairo.Color (
         (1.0 - alpha) * ca.R + alpha * cb.R,
         (1.0 - alpha) * ca.G + alpha * cb.G,
         (1.0 - alpha) * ca.B + alpha * cb.B);
 }
开发者ID:rubenv,项目名称:tripod,代码行数:7,代码来源:CairoExtensions.cs

示例3: PointsToRectangle

		public static Cairo.Rectangle PointsToRectangle (Cairo.PointD p1, Cairo.PointD p2, bool constrain)
		{
			// We want to create a rectangle that always has positive width/height
			double x, y, w, h;

			if (p1.Y <= p2.Y) {
				y = p1.Y;
				h = p2.Y - y + 1;
			} else {
				y = p2.Y;
				h = p1.Y - y + 1;
			}

			if (p1.X <= p2.X) {
				x = p1.X;

				if (constrain)
					w = h;
				else
					w = p2.X - x + 1;
			} else {
				x = p2.X;

				if (constrain) {
					w = h;
					x = p1.X - w;
				} else
					w = p1.X - x + 1;
			}

			return new Cairo.Rectangle (x, y, w, h);
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:32,代码来源:Utility.cs

示例4: ColorAdjustBrightness

 public static Cairo.Color ColorAdjustBrightness(Cairo.Color @base, double br)
 {
     double h, s, b;
     HsbFromColor(@base, out h, out s, out b);
     b = Math.Max(Math.Min(br, 1), 0);
     return ColorFromHsb(h, s, b);
 }
开发者ID:chergert,项目名称:custom-gtk-widgets,代码行数:7,代码来源:CarioExtensions.cs

示例5: DrawColumnHeaderFocus

        public override void DrawColumnHeaderFocus(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            double top_offset = 2.0;
            double right_offset = 2.0;

            double margin = 0.5;
            double line_width = 0.7;

            Cairo.Color stroke_color = CairoExtensions.ColorShade (
                CairoExtensions.GdkRGBAToCairoColor (
                    Widget.StyleContext.GetBackgroundColor (StateFlags.Selected)), 0.8);

            stroke_color.A = 0.1;
            cr.Color = stroke_color;

            CairoExtensions.RoundedRectangle (cr,
                alloc.X + margin + line_width + right_offset,
                alloc.Y + margin + line_width + top_offset,
                alloc.Width - (margin + line_width)*2.0 - right_offset,
                alloc.Height - (margin + line_width)*2.0 - top_offset,
                Context.Radius/2.0, CairoCorners.None);

            cr.Fill ();

            stroke_color.A = 1.0;
            cr.LineWidth = line_width;
            cr.Color = stroke_color;
            CairoExtensions.RoundedRectangle (cr,
                alloc.X + margin + line_width + right_offset,
                alloc.Y + margin + line_width + top_offset,
                alloc.Width - (line_width + margin)*2.0 - right_offset,
                alloc.Height - (line_width + margin)*2.0 - right_offset,
                Context.Radius/2.0, CairoCorners.All);
            cr.Stroke ();
        }
开发者ID:knocte,项目名称:hyena,代码行数:35,代码来源:GtkTheme.cs

示例6: UnderlineMarker

		public UnderlineMarker (Cairo.Color color, int start, int end)
		{
			this.Color = color;
			this.StartCol = start;
			this.EndCol = end;
			this.Wave = false;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:UnderlineMarker.cs

示例7: DrawContents

        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(24);

            Text.ShadowedText(g, MenuState.ConfigScreen.Control.Info, X + 20, Y + 27);
        }
开发者ID:skinitimski,项目名称:Reverence,代码行数:7,代码来源:Info.cs

示例8: OnDrawn

        protected override bool OnDrawn(Cairo.Context cr)
        {
            double step_width = Allocation.Width / (double)steps;
            double step_height = Allocation.Height / (double)steps;
            double h = 1.0;
            double s = 0.0;

            for (int xi = 0, i = 0; xi < steps; xi++) {
                for (int yi = 0; yi < steps; yi++, i++) {
                    double bg_b = (double)(i / 255.0);
                    double fg_b = 1.0 - bg_b;

                    double x = xi * step_width;
                    double y = yi * step_height;

                    cr.Rectangle (x, y, step_width, step_height);
                    cr.Color = CairoExtensions.ColorFromHsb (h, s, bg_b);
                    cr.Fill ();

                    int tw, th;
                    Pango.Layout layout = new Pango.Layout (PangoContext);
                    layout.SetText (((int)(bg_b * 255.0)).ToString ());
                    layout.GetPixelSize (out tw, out th);

                    cr.Translate (0.5, 0.5);
                    cr.MoveTo (x + (step_width - tw) / 2.0, y + (step_height - th) / 2.0);
                    cr.Color = CairoExtensions.ColorFromHsb (h, s, fg_b);
                    PangoCairoHelper.ShowLayout (cr, layout);
                    cr.Translate (-0.5, -0.5);
                }
            }

            return true;
        }
开发者ID:knocte,项目名称:hyena,代码行数:34,代码来源:ShadingTestWindow.cs

示例9: draw

	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		
		gr.MoveTo ( new PointD (0.5, 0.1) );
		gr.LineTo ( new PointD (0.9, 0.9) );
		gr.RelLineTo ( new Distance (-0.4, 0.0) );
		gr.CurveTo ( new PointD (0.2, 0.9),
			     new PointD ( 0.2, 0.5),
			     new PointD (0.5, 0.5)
			     );
		gr.ClosePath ();
		
		gr.MoveTo ( new PointD (0.25, 0.1) );
		gr.RelLineTo ( new Distance (0.2, 0.2) );
		gr.RelLineTo ( new Distance ( -0.2, 0.2) );
		gr.RelLineTo ( new Distance (-0.2, -0.2) );
		gr.ClosePath ();	       
		
		gr.Color = new Color (0, 0, 1, 1);
		gr.FillPreserve ();
		gr.Color = new Color ( 0, 0, 0, 1);
		gr.Stroke ();
	}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:25,代码来源:fillstroke.cs

示例10: DrawInRegionVisitor

 public DrawInRegionVisitor(Gdk.Region region, Cairo.Context context, IDrawingView view)
 {
     this.context = context;
     this.region = region;
     this.view = view;
     this.figures = new List<Figure> ();
 }
开发者ID:erbriones,项目名称:monodevelop-classdesigner,代码行数:7,代码来源:DrawInRegionVisitor.cs

示例11: Draw

		public void Draw (Cairo.Context g, double scale, bool fillSelection)
		{
			g.Save ();
			g.Translate (0.5, 0.5);
			g.Scale (scale, scale);
			
			g.AppendPath (SelectionPath);
			
			if (fillSelection)
			{
				g.SetSourceColor (new Cairo.Color (0.7, 0.8, 0.9, 0.2));
				g.FillRule = Cairo.FillRule.EvenOdd;
				g.FillPreserve ();
			}
			
			g.LineWidth = 1 / scale;
			
			// Draw a white line first so it shows up on dark backgrounds
			g.SetSourceColor (new Cairo.Color (1, 1, 1));
			g.StrokePreserve ();
			
			// Draw a black dashed line over the white line
			g.SetDash (new double[] { 2 / scale, 4 / scale }, 0);
			g.SetSourceColor (new Cairo.Color (0, 0, 0));
			
			g.Stroke ();
			g.Restore ();
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:28,代码来源:DocumentSelection.cs

示例12: DrawContent

		public override void DrawContent (Cairo.Context Context, Cairo.Rectangle Area)
		{
			Context.Color = new Color (0, 0, 0);
			Pango.CairoHelper.UpdateLayout (Context, textLayout);
			Context.MoveTo (Area.X, Area.Y);
			Pango.CairoHelper.ShowLayout (Context, textLayout);
		}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:7,代码来源:SampleTile.cs

示例13: CairoImageCellRenderer

 public CairoImageCellRenderer(int width, int height, Cairo.ImageSurface default_surface, RequestThumbnailEventHandler request_thumbnail)
 {
     this.width = width;
     this.height = height;
     this.default_surface = default_surface;
     this.request_thumbnail = request_thumbnail;
 }
开发者ID:GNOME,项目名称:mistelix,代码行数:7,代码来源:CairoImageCellRenderer.cs

示例14: DrawContents

        protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
        {
            g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
            g.SetFontSize(Text.FONT_SIZE_LABEL);

            Text.ShadowedText(g, "Equip", X + 20, Y + 25);
        }
开发者ID:skinitimski,项目名称:Reverence,代码行数:7,代码来源:Label.cs

示例15: draw

	static void draw (Cairo.Context gr, int width, int height)
	{
		double x=0.1,  y=0.5;
		double x1=0.4, y1=0.9, x2=0.6, y2=0.1, x3=0.9, y3=0.5;
		
				
		gr.Scale (width, height);
		gr.LineWidth = 0.04;		
		
		gr.MoveTo ( new PointD (x, y) );
		
		gr.CurveTo ( new PointD (x1, y1),
			     new PointD (x2, y2), 
			     new PointD (x3, y3)
			     );
		
		gr.Stroke ();
		
		gr.Color = new Color (1, 0.2, 0.2, 0.6);
		gr.LineWidth = 0.03;
		gr.MoveTo ( new PointD (x, y) );
		gr.LineTo ( new PointD (x1, y1) );
		gr.MoveTo ( new PointD (x2, y2) );
		gr.LineTo ( new PointD (x3, y3) );
		gr.Stroke ();						
	}
开发者ID:nlhepler,项目名称:mono,代码行数:26,代码来源:curve_to.cs


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