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


C# Context.ClipPreserve方法代码示例

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


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

示例1: clearAndClip

        public void clearAndClip(Context ctx)
        {
            if (list.Count == 0)
                return;
            foreach (Rectangle r in list)
                ctx.Rectangle(r);

            ctx.ClipPreserve();
            ctx.Operator = Operator.Clear;
            ctx.Fill();
            ctx.Operator = Operator.Over;
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:12,代码来源:Rectangles.cs

示例2: DrawRibbon

        /// <summary>Draws a ribbon.</summary>
        public void DrawRibbon(Context cr, Gdk.Rectangle menuBarAllocation, Gdk.Rectangle bodyAllocation, double roundSize, double lineWidth, Ribbon widget)
        {
            double lineWidth05 = lineWidth / 2;
            double lineWidth15 = 3 * lineWidth05;
            double x0, x1, y0, y1;
            LinearGradient linGrad;

            if(menuBarAllocation.Height > 0)
            {
                cr.Rectangle (menuBarAllocation.X, menuBarAllocation.Y, menuBarAllocation.Width, menuBarAllocation.Height - 1);
                linGrad = new LinearGradient (0, menuBarAllocation.Y, 0, menuBarAllocation.Y + menuBarAllocation.Height - 1);
                linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.5));
                linGrad.AddColorStop (0.3, new Color (1, 1, 1, 0.2));
                linGrad.AddColorStop (0.3, new Color (1, 1, 1, 0.0));
                linGrad.AddColorStop (1.0, new Color (1, 1, 1, 0.5));
                cr.Pattern = linGrad;
                cr.Fill ();
                linGrad.Destroy ();

                cr.MoveTo (menuBarAllocation.X, menuBarAllocation.Bottom + 0.5);
                cr.LineTo (menuBarAllocation.Right, menuBarAllocation.Bottom + 0.5);
                cr.Color = new Color (1, 1, 1, 0.5);
                cr.LineWidth = 1;
                cr.Stroke ();

                // Quick Access Toolbar background

                Gdk.Rectangle alloc = widget.QuickAccessToolbar.Allocation;
                x0 = alloc.X;
                x1 = alloc.Right - 1;
                y0 = alloc.Y;
                y1 = alloc.Bottom - 1;
                double radius = (y1 - y0) / 2;

                cr.LineWidth = 1;

                if(widget.ApplicationButton != null)
                {
                    Gdk.Rectangle alloc2 = widget.ApplicationButton.Allocation;
                    double cx = alloc2.X + alloc2.Width / 2;
                    double cy = alloc2.Y + alloc2.Height / 2;
                    double radius2 = x0 - cx;
                    double alpha = Math.Asin ((y0 - cy) / radius2);
                    double beta = Math.Asin ((y1 - cy) / radius2);
                    double curveWidth0 = Math.Cos (Math.Abs (alpha)) * radius2;
                    double curveWidth1 = Math.Cos (Math.Abs (beta)) * radius2;
                    double curveWidth = Math.Min (curveWidth0, curveWidth1);

                    cr.Save ();
                    cr.Rectangle (cx + curveWidth, y0, x1 - cx - curveWidth, alloc.Height);
                    cr.ClipPreserve ();
                    cr.ArcNegative (cx, cy, radius2, -alpha, -beta);
                    linGrad = new LinearGradient (0, y0, 0, y1);
                    linGrad.AddColorStop (0.0, colorScheme.Bright);
                    linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                    cr.Pattern = linGrad;
                    //cr.Color = new Color (1, 0, 0);
                    cr.Fill ();
                    cr.Restore ();
                    cr.Arc (x1, y0 + radius, radius - 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
                    cr.Pattern = linGrad;
                    cr.Fill ();
                    linGrad.Destroy ();

                    cr.Arc (cx, cy, radius2, alpha, beta);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();
                    radius2 -= 1;
                    cr.Arc (cx, cy, radius2, alpha, beta);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth0, y0 - 0.5);
                    cr.LineTo (x1, y0 - 0.5);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth0, y0 + 0.5);
                    cr.LineTo (x1, y0 + 0.5);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth1, y1 - 0.5);
                    cr.LineTo (x1, y1 - 0.5);
                    cr.Color = new Color (0, 0, 0, 0.6);
                    cr.Stroke ();

                    cr.MoveTo (cx + curveWidth1, y1 + 0.5);
                    cr.LineTo (x1, y1 + 0.5);
                    cr.Color = new Color (1, 1, 1, 0.4);
                    cr.Stroke ();
                }
                else
                {
                    cr.Rectangle (x0, y0, x1 - x0, alloc.Height);
                    linGrad = new LinearGradient (0, y0, 0, y1);
                    linGrad.AddColorStop (0.0, colorScheme.Bright);
                    linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
                    cr.Pattern = linGrad;
//.........这里部分代码省略.........
开发者ID:MASGAU,项目名称:gtk-sharp-ribbon,代码行数:101,代码来源:Theme.cs


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