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


C# Context.AppendPath方法代码示例

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


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

示例1: OnFillRegionComputed

        protected unsafe override void OnFillRegionComputed(Point[][] polygonSet)
        {
            SimpleHistoryItem hist = new SimpleHistoryItem (Icon, Name);
            hist.TakeSnapshotOfLayer (PintaCore.Layers.CurrentLayer);

            PintaCore.Layers.ToolLayer.Clear ();
            ImageSurface surface = PintaCore.Layers.ToolLayer.Surface;

            ColorBgra* surf_data_ptr = (ColorBgra*)surface.DataPtr;
            int surf_width = surface.Width;

            for (int x = 0; x < stencil.Width; x++)
                for (int y = 0; y < stencil.Height; y++)
                    if (stencil.GetUnchecked (x, y))
                        surface.SetPixel (surf_data_ptr, surf_width, x, y, fill_color);

            using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
                g.AppendPath (PintaCore.Layers.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = Antialias.Subpixel;

                g.SetSource (surface);
                g.Paint ();
            }

            PintaCore.History.PushNewItem (hist);
            PintaCore.Workspace.Invalidate ();
        }
开发者ID:xxgreg,项目名称:Pinta,代码行数:30,代码来源:PaintBucketTool.cs

示例2: Clone

        public static Path Clone(this Path path)
        {
            Path newpath;

            using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
                g.AppendPath (path);
                newpath = g.CopyPath ();
            }

            return newpath;
        }
开发者ID:xxgreg,项目名称:Pinta,代码行数:11,代码来源:CairoExtensions.cs

示例3: Clear

        /// <summary>
        /// Erase the handle that was drawn in a previous call to Render ().
        /// </summary>
        public void Clear (Context g)
        {
            g.Save ();

            var rect = GetHandleRect ().Inflate (2, 2);
            using (var path = g.CreateRectanglePath (rect))
                g.AppendPath (path);
            g.Operator = Operator.Clear;
            g.Fill ();

            g.Restore ();
        }
开发者ID:msiyer,项目名称:Pinta,代码行数:15,代码来源:ToolControl.cs

示例4: OnFillRegionComputed

        protected unsafe override void OnFillRegionComputed(Point[][] polygonSet)
        {
            SimpleHistoryItem hist = new SimpleHistoryItem (Icon, Name);
            hist.TakeSnapshotOfLayer (PintaCore.Layers.CurrentLayer);

            using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
                g.AppendPath (PintaCore.Layers.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                // Reset FillRule to the default
                g.FillRule = FillRule.Winding;
                g.AppendPath (g.CreatePolygonPath (polygonSet));

                g.Antialias = Antialias.Subpixel;

                g.Color = fill_color;
                g.Fill ();
            }

            PintaCore.History.PushNewItem (hist);
            PintaCore.Workspace.Invalidate ();
        }
开发者ID:sandyarmstrong,项目名称:Pinta,代码行数:23,代码来源:PaintBucketTool.cs

示例5: DrawShape

        protected override Rectangle DrawShape(Rectangle rect, Layer l)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            Rectangle dirty;

            using (Context g = new Context (l.Surface)) {
                g.AppendPath (doc.Selection.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                dirty = g.DrawLine (shape_origin, current_point , outline_color, BrushWidth);
            }

            return dirty;
        }
开发者ID:bodicsek,项目名称:Pinta,代码行数:18,代码来源:LineCurveTool.cs

示例6: DrawShape

        protected override Rectangle DrawShape(Rectangle rect, Layer l)
        {
            Rectangle dirty;

            using (Context g = new Context (l.Surface)) {
                g.AppendPath (PintaCore.Layers.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = Antialias.Subpixel;

                if (FillShape && StrokeShape)
                    dirty = g.FillStrokedRectangle (rect, fill_color, outline_color, BrushWidth);
                else if (FillShape)
                    dirty = g.FillRectangle (rect, outline_color);
                else
                    dirty = g.DrawRectangle (rect, outline_color, BrushWidth);
            }

            return dirty;
        }
开发者ID:joehillen,项目名称:Pinta,代码行数:21,代码来源:RectangleTool.cs

示例7: Form1_Shown

        private void Form1_Shown(object sender, EventArgs e)
        {
            Debug.WriteLine("Form1_Shown");

            surface = new Win32Surface(this.CreateGraphics().GetHdc());
            context = new Context(surface);

            textFormat = DWriteCairo.CreateTextFormat(
                "Consolas",
                FontWeight.Normal,
                FontStyle.Normal,
                FontStretch.Normal,
                12);

            textFormat.TextAlignment = TextAlignment.Center;
            
            float left, top, width, height;

            // get actual size of the text
            var measureLayout = DWriteCairo.CreateTextLayout(s, textFormat, 4096, 4096);
            measureLayout.GetRect(out left, out top, out width, out height);
            measureLayout.Dispose();

            // build text context against the size and format
            textLayout = DWriteCairo.CreateTextLayout(s, textFormat, (int)Math.Ceiling(width), (int)Math.Ceiling(height));

            Debug.WriteLine("showing layout");
            Path path = DWriteCairo.RenderLayoutToCairoPath(context, textLayout);
            context.AppendPath(path);
            context.Fill();

            textLayout.GetRect(out left, out top, out width, out height);
            textRect = new System.Drawing.RectangleF(left, top, width, height);
            context.Rectangle(left, top, width, height);
            context.Stroke();

            context.GetTarget().Flush();
        }
开发者ID:zwcloud,项目名称:ZWCloud.DwriteCairo,代码行数:38,代码来源:Form1.cs

示例8: DrawShape

        protected override Rectangle DrawShape(Rectangle rect, Layer l)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            Rectangle dirty;

            using (Context g = new Context (l.Surface)) {
                g.AppendPath (doc.Selection.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                if (FillShape && StrokeShape)
                    dirty = g.FillStrokedRectangle (rect, fill_color, outline_color, BrushWidth);
                else if (FillShape)
                    dirty = g.FillRectangle (rect, outline_color);
                else
                    dirty = g.DrawRectangle (rect, outline_color, BrushWidth);
            }

            return dirty;
        }
开发者ID:Kharevich,项目名称:Pinta,代码行数:23,代码来源:RectangleTool.cs

示例9: OnMouseUp

        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            base.OnMouseUp (canvas, args, point);

            ImageSurface surf = PintaCore.Layers.CurrentLayer.Surface;

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

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

                Path old = PintaCore.Layers.SelectionPath;

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

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

示例10: OnMouseMove

        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            if (mouse_button == 1) {
                StrokeColor = PintaCore.Palette.PrimaryColor;
                FillColor = PintaCore.Palette.SecondaryColor;
            } else if (mouse_button == 3) {
                StrokeColor = PintaCore.Palette.SecondaryColor;
                FillColor = PintaCore.Palette.PrimaryColor;
            } else {
                LastPoint = point_empty;
                return;
            }

            // TODO: also multiply by pressure
            StrokeColor = new Color (StrokeColor.R, StrokeColor.G, StrokeColor.B,
                StrokeColor.A * active_brush.StrokeAlphaMultiplier);

            int x = (int)point.X;
            int y = (int)point.Y;

            if (LastPoint.Equals (point_empty))
                LastPoint = new Point (x, y);

            if (PintaCore.Workspace.PointInCanvas (point))
                surface_modified = true;

            var surf = PintaCore.Layers.CurrentLayer.Surface;
            var invalidate_rect = Gdk.Rectangle.Zero;
            var brush_width = BrushWidth;

            using (Drawable = new Context (surf)) {
                Drawable.AppendPath (PintaCore.Workspace.ActiveDocument.SelectionPath);
                Drawable.FillRule = FillRule.EvenOdd;
                Drawable.Clip ();

                Drawable.Antialias = Antialias.Subpixel;
                Drawable.LineWidth = brush_width;
                Drawable.LineJoin = LineJoin.Round;
                Drawable.LineCap = BrushWidth == 1 ? LineCap.Butt : LineCap.Round;
                Drawable.Color = StrokeColor;

                Drawable.Translate (brush_width / 2.0, brush_width / 2.0);

                active_brush.Tool = this;
                invalidate_rect = active_brush.DoMouseMove (x, y, LastPoint.X, LastPoint.Y);
                active_brush.Tool = null;
            }

            Drawable = null;

            if (invalidate_rect.IsEmpty) {
                PintaCore.Workspace.Invalidate ();
            } else {
                PintaCore.Workspace.Invalidate (invalidate_rect);
            }

            LastPoint = new Point (x, y);
        }
开发者ID:linuxmhall,项目名称:Pinta,代码行数:58,代码来源:PaintBrushTool.cs

示例11: OnMouseMove

        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            Color tool_color;

            if ((args.Event.State & Gdk.ModifierType.Button1Mask) == Gdk.ModifierType.Button1Mask)
                tool_color = PintaCore.Palette.PrimaryColor;
            else if ((args.Event.State & Gdk.ModifierType.Button3Mask) == Gdk.ModifierType.Button3Mask)
                tool_color = PintaCore.Palette.SecondaryColor;
            else {
                last_point = point_empty;
                return;
            }

            DrawingArea drawingarea1 = (DrawingArea)o;

            int x = (int)point.X;
            int y = (int)point.Y;

            if (last_point.Equals (point_empty)) {
                last_point = new Point (x, y);
                return;
            }

            if (PintaCore.Workspace.PointInCanvas (point))
                surface_modified = true;

            ImageSurface surf = PintaCore.Layers.CurrentLayer.Surface;

            using (Context g = new Context (surf)) {
                g.AppendPath (PintaCore.Layers.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip ();

                g.Antialias = Antialias.None;

                g.MoveTo (last_point.X, last_point.Y);
                g.LineTo (x, y);

                g.Color = tool_color;
                g.LineWidth = 1;
                g.LineCap = LineCap.Square;

                g.Stroke ();
            }

            Gdk.Rectangle r = GetRectangleFromPoints (last_point, new Point (x, y));

            PintaCore.Workspace.Invalidate (r);

            last_point = new Point (x, y);
        }
开发者ID:xxgreg,项目名称:Pinta,代码行数:51,代码来源:PencilTool.cs

示例12: OnMouseMove

        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            base.OnMouseMove (o, args, point);
            if (tracking) {

                UserBlendOps.NormalBlendOp normalBlendOp = new UserBlendOps.NormalBlendOp();
                GradientRenderer gr = null;
                switch (GradientType) {
                    case eGradientType.Linear:
                        gr = new GradientRenderers.LinearClamped (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.LinearReflected:
                        gr = new GradientRenderers.LinearReflected (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Radial:
                        gr = new GradientRenderers.Radial (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Diamond:
                        gr = new GradientRenderers.LinearDiamond (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                    case eGradientType.Conical:
                        gr = new GradientRenderers.Conical (GradientColorMode  == GradientColorMode.Transparency, normalBlendOp);
                    break;
                }
                if (button == 3) {//right
                    gr.StartColor = PintaCore.Palette.SecondaryColor.ToColorBgra ();
                    gr.EndColor = PintaCore.Palette.PrimaryColor.ToColorBgra ();
                }
                else {//1 left
                    gr.StartColor = PintaCore.Palette.PrimaryColor.ToColorBgra ();
                    gr.EndColor = PintaCore.Palette.SecondaryColor.ToColorBgra ();
                }

                gr.StartPoint = startpoint;
                gr.EndPoint = point;
                gr.AlphaBlending = UseAlphaBlending;

                gr.BeforeRender ();

                Gdk.Rectangle selection_bounds = PintaCore.Layers.SelectionPath.GetBounds ();
                ImageSurface scratch_layer = PintaCore.Layers.ToolLayer.Surface;

                gr.Render (scratch_layer, new Gdk.Rectangle[] { selection_bounds });

                using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
                    g.AppendPath (PintaCore.Layers.SelectionPath);
                    g.FillRule = FillRule.EvenOdd;
                    g.Clip ();

                    g.SetSource (scratch_layer);
                    g.Paint ();
                }

                selection_bounds.Inflate (5, 5);
                PintaCore.Workspace.Invalidate (selection_bounds);
            }
        }
开发者ID:rikky,项目名称:Pinta,代码行数:57,代码来源:GradientTool.cs

示例13: HandlePintaCoreActionsEditFillSelectionActivated

        private void HandlePintaCoreActionsEditFillSelectionActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            Cairo.ImageSurface old = doc.CurrentLayer.Surface.Clone ();

            using (var g = new Cairo.Context (doc.CurrentLayer.Surface)) {
                g.AppendPath (doc.SelectionPath);
                g.FillRule = FillRule.EvenOdd;

                g.Color = PintaCore.Palette.PrimaryColor;
                g.Fill ();
            }

            doc.Workspace.Invalidate ();
            doc.History.PushNewItem (new SimpleHistoryItem ("Menu.Edit.FillSelection.png", Catalog.GetString ("Fill Selection"), old, doc.CurrentLayerIndex));
        }
开发者ID:rolandixor,项目名称:Pinta,代码行数:19,代码来源:EditActions.cs

示例14: HandlerPintaCoreActionsEditCutActivated

        private void HandlerPintaCoreActionsEditCutActivated(object sender, EventArgs e)
        {
            PintaCore.Layers.FinishSelection ();

            // Copy selection
            HandlerPintaCoreActionsEditCopyActivated (sender, e);

            // Erase selection
            Cairo.ImageSurface old = PintaCore.Layers.CurrentLayer.Surface.Clone ();

            using (Cairo.Context g = new Cairo.Context (PintaCore.Layers.CurrentLayer.Surface)) {
                g.AppendPath (PintaCore.Layers.SelectionPath);
                g.FillRule = Cairo.FillRule.EvenOdd;
                g.Operator = Cairo.Operator.Clear;
                g.Fill ();
            }

            PintaCore.Workspace.Invalidate ();
            PintaCore.History.PushNewItem (new SimpleHistoryItem ("Menu.Edit.EraseSelection.png", Mono.Unix.Catalog.GetString ("Cut"), old, PintaCore.Layers.CurrentLayerIndex));
        }
开发者ID:asbjornu,项目名称:Pinta,代码行数:20,代码来源:EditActions.cs

示例15: Clip

 public void Clip(Context g)
 {
     g.AppendPath (selection_path);
     g.FillRule = FillRule.EvenOdd;
     g.Clip ();
 }
开发者ID:bodicsek,项目名称:Pinta,代码行数:6,代码来源:DocumentSelection.cs


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