本文整理汇总了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;
}
示例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;
//.........这里部分代码省略.........