本文整理汇总了C#中Cairo.LinearGradient.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# LinearGradient.Dispose方法的具体用法?C# LinearGradient.Dispose怎么用?C# LinearGradient.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.LinearGradient
的用法示例。
在下文中一共展示了LinearGradient.Dispose方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawColumnHighlight
public void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
{
Cairo.Color light_color = CairoExtensions.ColorShade (color, 1.6);
Cairo.Color dark_color = CairoExtensions.ColorShade (color, 1.3);
LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom - 1);
grad.AddColorStop (0, light_color);
grad.AddColorStop (1, dark_color);
cr.SetSource (grad);
cr.Rectangle (alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
cr.Fill ();
grad.Dispose ();
}
示例2: DrawFrameBorder
public override void DrawFrameBorder(Cairo.Context cr, Gdk.Rectangle alloc)
{
cr.LineWidth = BorderWidth;
border_color.A = 0.3;
cr.SetSourceColor (border_color);
double offset = (double)BorderWidth / 2.0;
double w = Math.Max (0, alloc.Width * 0.75);
double x = alloc.X + (alloc.Width - w) * 0.5 + offset;
double y = alloc.Y + alloc.Height + offset;
LinearGradient g = new LinearGradient (x, y, x + w, y);
Color transparent = border_color;
transparent.A = 0.0;
g.AddColorStop (0, transparent);
g.AddColorStop (0.4, border_color);
g.AddColorStop (0.6, border_color);
g.AddColorStop (1, transparent);
cr.SetSource (g);
cr.MoveTo (x, y);
cr.LineTo (x + w, y);
cr.Stroke ();
g.Dispose ();
}
示例3: gradientToolStripMenuItem_Click
private void gradientToolStripMenuItem_Click(object sender, EventArgs e)
{
lastSelected = "gradient";
OnPaintAction = cr =>
{
Gradient pat = new LinearGradient(0.0, 0.0, 0.0, 256.0);
pat.AddColorStopRgba(1, 0, 0, 0, 1);
pat.AddColorStopRgba(0, 1, 1, 1, 1);
cr.Rectangle(0, 0, 256, 256);
cr.SetSource(pat);
cr.Fill();
pat.Dispose();
pat = new RadialGradient(115.2, 102.4, 25.6,
102.4, 102.4, 128.0);
pat.AddColorStopRgba(0, 1, 1, 1, 1);
pat.AddColorStopRgba(1, 0, 0, 0, 1);
cr.SetSource(pat);
cr.Arc(128.0, 128.0, 76.8, 0, 2 * Math.PI);
cr.Fill();
pat.Dispose();
};
Invalidate();
}
示例4: DrawRowSelection
public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
{
color.A *= 0.85;
Cairo.Color selection_color = color;
Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
selection_stroke.A = color.A;
if (filled) {
Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.05);
Cairo.Color selection_fill_dark = selection_color;
selection_fill_light.A = color.A;
selection_fill_dark.A = color.A;
LinearGradient grad = new LinearGradient (x, y, x, y + height);
grad.AddColorStop (0, selection_fill_dark);
grad.AddColorStop (1, selection_fill_light);
cr.SetSource (grad);
cr.Rectangle (x, y, width, height);
cr.Fill ();
grad.Dispose ();
}
if (stroked && !filled) {
cr.LineWidth = 1.0;
cr.SetSourceColor (selection_stroke);
cr.Rectangle (x + 0.5, y + 0.5, width - 1, height - 1);
cr.Stroke ();
}
}
示例5: DrawHeaderBackground
public override void DrawHeaderBackground (Cairo.Context cr, Gdk.Rectangle alloc)
{
Cairo.Color gtk_background_color = Colors.GetWidgetColor (GtkColorClass.Background, StateType.Normal);
Cairo.Color light_color = CairoExtensions.ColorShade (gtk_background_color, 1.1);
Cairo.Color dark_color = CairoExtensions.ColorShade (gtk_background_color, 0.95);
CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;
LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom);
grad.AddColorStop (0, light_color);
grad.AddColorStop (0.75, dark_color);
grad.AddColorStop (0, light_color);
cr.SetSource (grad);
CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
cr.Fill ();
cr.SetSourceColor (border_color);
cr.Rectangle (alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
cr.Fill ();
grad.Dispose ();
}
示例6: ClippedRender
protected override void ClippedRender(Cairo.Context cr)
{
LinearGradient grad = new LinearGradient (0, 0, RenderSize.Width, RenderSize.Height);
grad.AddColorStop (0, new Color (0.5, 0.5, 0.5));
grad.AddColorStop (1, new Color (0, 0, 0));
cr.SetSource (grad);
cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
cr.Fill ();
grad.Dispose ();
base.ClippedRender (cr);
}
示例7: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
if (evnt.Window != GdkWindow) {
return base.OnExposeEvent (evnt);
}
Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window);
if (reflect) {
CairoExtensions.PushGroup (cr);
}
cr.Operator = Operator.Over;
cr.Translate (Allocation.X + h_padding, Allocation.Y);
cr.Rectangle (0, 0, Allocation.Width - h_padding, Math.Max (2 * bar_height,
bar_height + bar_label_spacing + layout_height));
cr.Clip ();
Pattern bar = RenderBar (Allocation.Width - 2 * h_padding, bar_height);
cr.Save ();
cr.SetSource (bar);
cr.Paint ();
cr.Restore ();
if (reflect) {
cr.Save ();
cr.Rectangle (0, bar_height, Allocation.Width - h_padding, bar_height);
cr.Clip ();
Matrix matrix = new Matrix ();
matrix.InitScale (1, -1);
matrix.Translate (0, -(2 * bar_height) + 1);
cr.Transform (matrix);
cr.SetSource (bar);
LinearGradient mask = new LinearGradient (0, 0, 0, bar_height);
mask.AddColorStop (0.25, new Color (0, 0, 0, 0));
mask.AddColorStop (0.5, new Color (0, 0, 0, 0.125));
mask.AddColorStop (0.75, new Color (0, 0, 0, 0.4));
mask.AddColorStop (1.0, new Color (0, 0, 0, 0.7));
cr.Mask (mask);
mask.Dispose ();
cr.Restore ();
CairoExtensions.PopGroupToSource (cr);
cr.Paint ();
}
if (show_labels) {
cr.Translate ((reflect ? Allocation.X : -h_padding) + (Allocation.Width - layout_width) / 2,
(reflect ? Allocation.Y : 0) + bar_height + bar_label_spacing);
RenderLabels (cr);
}
bar.Dispose ();
CairoExtensions.DisposeContext (cr);
return true;
}
示例8: UpdateBgImage
void UpdateBgImage()
{
m_bgImage = null;
if (TextColumn < 0 || WeightColumn < 0)
return;
m_bgImage = new Cairo.ImageSurface (Format.Rgb24, Allocation.Width, this.Allocation.Height);
using (var c = new Cairo.Context (m_bgImage))
{
// Paint the default background (linear gradient)
var g = new Cairo.LinearGradient (0, 0, 1, this.Allocation.Height);
g.AddColorStop (0.2, CairoExtensions.GdkColorToCairoColor (m_Background));
g.AddColorStop (0.9, CairoExtensions.GdkColorToCairoColor (this.Style.Background (Gtk.StateType.Normal)));
c.Rectangle (0, 0, this.Allocation.Width, this.Allocation.Height);
c.Pattern = g;
c.Paint ();
g.Dispose ();
Gtk.TreeIter iter;
List<TreeMapItem> rootItems = new List<TreeMapItem> ();
if (m_Model.GetIterFirst (out iter)) {
do {
var item = new TreeMapItem (m_Model, ref iter, true, m_TextColumn, m_WeightColumn);
rootItems.Add (item);
} while (m_Model.IterNext (ref iter));
double t = 0.0;
rootItems.ForEach (delegate (TreeMapItem i) {
t += Math.Abs (i.Weight);
});
double x = 0, y = 0, w = this.Allocation.Width, h = this.Allocation.Height;
double myx = 0, myy = 0, myw = 0, myh = 0;
rootItems.ForEach (delegate (TreeMapItem i) {
var ratio = Math.Abs (i.Weight) / t;
myx = x;
myy = y;
myw = w * ratio;
myh = h;
x += myw;
i.SetArea (myx, myy, myw, myh);
i.Render (c, m_Background);
});
// clear right away to lower refs
if (this.m_rootItems != null)
this.m_rootItems.Clear ();
this.m_rootItems = rootItems;
}
}
}
示例9: DrawHeaderBackground
public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc)
{
CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;
LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom);
grad.AddColorStop (0, CairoExtensions.RgbToColor (0xf6f3f3));
grad.AddColorStop (0.33, CairoExtensions.RgbToColor (0xeeecec));
grad.AddColorStop (0.66, CairoExtensions.RgbToColor (0xeeecec));
grad.AddColorStop (1, CairoExtensions.RgbToColor (0xe1dfdf));
cr.SetSource (grad);
CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
cr.Fill ();
cr.SetSourceColor (CairoExtensions.RgbToColor (0x919191));
cr.Rectangle (alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
cr.Fill ();
grad.Dispose ();
}
示例10: RenderGoo
private void RenderGoo (Context cr)
{
double max_r = Height / 2;
double x_ofs = Width / RenderPoints.Length;
double xc = 0, yc = Height;
double r;
double min_x = Width, max_x = 0, min_y = Height, max_y = yc;
for (int i = 0, n = RenderPoints.Length; i < n; i++) {
xc += x_ofs;
r = Height * RenderPoints[i];
cr.MoveTo (xc, yc);
cr.Arc (xc, yc, r, 0, 2 * Math.PI);
if (r > 0) {
min_x = Math.Min (min_x, xc - r);
max_x = Math.Max (max_x, xc + r);
min_y = Math.Min (min_y, yc - r);
}
}
render_damage = new Gdk.Rectangle (
(int)Math.Floor (min_x),
(int)Math.Floor (min_y),
(int)Math.Ceiling (max_x - min_x),
(int)Math.Ceiling (max_y - min_y)
);
cr.ClosePath ();
var grad = new LinearGradient (0, 0, 0, Height);
Color c = Color;
c.A = 0;
grad.AddColorStop (0, c);
c.A = RenderLoudness / 2;
grad.AddColorStop (1, c);
cr.SetSource (grad);
cr.Fill ();
grad.Dispose ();
}
示例11: ClippedRender
protected override void ClippedRender (Hyena.Data.Gui.CellContext context)
{
if (!EnsureLayout ()) {
return;
}
var cr = context.Context;
Foreground = new Brush (context.Theme.Colors.GetWidgetColor (
context.TextAsForeground ? GtkColorClass.Foreground : GtkColorClass.Text, context.State));
Brush foreground = Foreground;
if (!foreground.IsValid) {
return;
}
cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
cr.Clip ();
bool fade = Fade && text_alloc.Width > RenderSize.Width;
if (fade) {
cr.PushGroup ();
}
cr.MoveTo (text_alloc.X, text_alloc.Y);
Foreground.Apply (cr);
UpdateLayout (GetText (), RenderSize.Width, RenderSize.Height, true);
if (Hyena.PlatformDetection.IsWindows) {
// FIXME windows; working around some unknown issue with ShowLayout; bgo#644311
cr.Antialias = Cairo.Antialias.None;
PangoCairoHelper.LayoutPath (cr, layout, true);
} else {
PangoCairoHelper.ShowLayout (cr, layout);
}
cr.Fill ();
TooltipMarkup = layout.IsEllipsized ? last_formatted_text : null;
if (fade) {
LinearGradient mask = new LinearGradient (RenderSize.Width - 20, 0, RenderSize.Width, 0);
mask.AddColorStop (0, new Color (0, 0, 0, 1));
mask.AddColorStop (1, new Color (0, 0, 0, 0));
cr.PopGroupToSource ();
cr.Mask (mask);
mask.Dispose ();
}
cr.ResetClip ();
}