本文整理汇总了C#中Cairo.LinearGradient.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.LinearGradient.Dispose方法的具体用法?C# Cairo.LinearGradient.Dispose怎么用?C# Cairo.LinearGradient.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.LinearGradient
的用法示例。
在下文中一共展示了Cairo.LinearGradient.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawShadow
void DrawShadow(Cairo.Context ctx, Gdk.Rectangle ar, PositionType pos, List<Section> secs)
{
foreach (Section s in secs) {
Cairo.Gradient pat = null;
Gdk.Rectangle r = ar;
switch (pos) {
case PositionType.Top:
r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
r.X += s.Offset;
r.Width = s.Size;
pat = new Cairo.LinearGradient (r.X, r.Y, r.X, r.Bottom);
break;
case PositionType.Bottom:
r.Y = r.Bottom - shadowSize;
r.Height = shadowSize > r.Height ? r.Height / 2 : shadowSize;
r.X = r.X + s.Offset;
r.Width = s.Size;
pat = new Cairo.LinearGradient (r.X, r.Bottom, r.X, r.Y);
break;
case PositionType.Left:
r.Width = shadowSize > r.Width ? r.Width / 2 : shadowSize;
r.Y += s.Offset;
r.Height = s.Size;
pat = new Cairo.LinearGradient (r.X, r.Y, r.Right, r.Y);
break;
case PositionType.Right:
r.X = r.Right - shadowSize;
r.Width = shadowSize > r.Width ? r.Width / 2 : shadowSize;
r.Y += s.Offset;
r.Height = s.Size;
pat = new Cairo.LinearGradient (r.Right, r.Y, r.X, r.Y);
break;
}
Cairo.Color c = darkColor.ToCairoColor ();
pat.AddColorStop (0, c);
c.A = 0;
pat.AddColorStop (1, c);
ctx.NewPath ();
ctx.Rectangle (r.X, r.Y, r.Width, r.Height);
ctx.Pattern = pat;
ctx.Fill ();
pat.Dispose ();
}
}
示例2: SetAsSource
public override void SetAsSource(Cairo.Context ctx, Rectangle bounds = default(Rectangle))
{
Cairo.Gradient grad = null;
switch (GradientType) {
case Type.Vertical:
grad = new Cairo.LinearGradient (bounds.Left, bounds.Top, bounds.Left, bounds.Bottom);
break;
case Type.Horizontal:
grad = new Cairo.LinearGradient (bounds.Left, bounds.Top, bounds.Right, bounds.Top);
break;
case Type.Oblic:
grad = new Cairo.LinearGradient (bounds.Left, bounds.Top, bounds.Right, bounds.Bottom);
break;
case Type.Radial:
throw new NotImplementedException ();
}
foreach (ColorStop cs in Stops)
grad.AddColorStop (cs.Offset, cs.Color);
ctx.SetSource (grad);
grad.Dispose ();
}
示例3: RenderBackground
private void RenderBackground(Cairo.Context cr)
{
rand = rand ?? new Random ();
if (circles == null) {
for (int i = 0, n = rand.Next (100, 150); i < n; i++) {
circles = circles ?? new Circle[n];
circles[i] = new Circle {
X = rand.Next (0, Screen.Width),
Y = rand.Next (0, Screen.Height),
R = rand.Next (10, 70),
A = rand.NextDouble () * 0.08
};
}
}
Gdk.Rectangle damage = new Gdk.Rectangle();
cr.RenderDamage (damage);
//cr.Rectangle (damage.X, damage.Y, damage.Width, damage.Height);
//cr.Clip ();
cr.Translate (Allocation.X, Allocation.Y);
cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
if (render_gradient) {
var grad = new Cairo.LinearGradient (0, 0, 0, Allocation.Height);
grad.AddColorStop (0.7, CairoExtensions.GdkRGBAToCairoColor (StyleContext.GetBackgroundColor (StateFlags.Prelight)));
grad.AddColorStop (1, CairoExtensions.GdkRGBAToCairoColor (StyleContext.GetBackgroundColor (StateFlags.Normal)));
cr.SetSource (grad);
cr.Fill ();
grad.Dispose ();
foreach (var circle in circles) {
cr.SetSourceColor (new Cairo.Color (0, 0, 0, circle.A));
cr.Arc (circle.X + circle.R, circle.Y + circle.R, circle.R, 0, 2 * Math.PI);
cr.Fill ();
}
} else {
cr.SetSourceColor (new Cairo.Color (1, 1, 1));
cr.Fill ();
}
if (window_decorator != null) {
window_decorator.Render (cr);
}
if (render_debug) {
cr.LineWidth = 1.0;
cr.SetSourceColor (CairoExtensions.RgbToColor (
(uint)rand.Next (0, 0xffffff)));
cr.Rectangle (damage.X + 0.5, damage.Y + 0.5, damage.Width - 1, damage.Height - 1);
cr.Stroke ();
}
cr.ResetClip ();
}