本文整理汇总了C#中Cairo.LinearGradient.Destroy方法的典型用法代码示例。如果您正苦于以下问题:C# LinearGradient.Destroy方法的具体用法?C# LinearGradient.Destroy怎么用?C# LinearGradient.Destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.LinearGradient
的用法示例。
在下文中一共展示了LinearGradient.Destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: draw
static void draw (Cairo.Context gr, int width, int height)
{
gr.Scale (width, height);
gr.LineWidth = 0.04;
LinearGradient pat;
pat = new LinearGradient (0.0, 0.0, 0.0, 1.0);
pat.AddColorStop (1, new Color (0, 0, 0, 1) );
pat.AddColorStop (0, new Color (1, 1, 1, 1) );
gr.Rectangle ( new PointD (0, 0),
1, 1
);
gr.Pattern = pat;
gr.Fill ();
pat.Destroy ();
RadialGradient pat2 = new RadialGradient (0.45, 0.4, 0.1,
0.4, 0.4, 0.5);
pat2.AddColorStop (0, new Color (1, 1, 1, 1) );
pat2.AddColorStop (1, new Color (0, 0, 0, 1) );
gr.Pattern = pat2;
gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
gr.Fill ();
pat2.Destroy ();
}
示例2: DrawRowSelection
public override void DrawRowSelection (Cairo.Context cr, int x, int y, int width, int height, bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
{
Cairo.Color selection_color = color;
Cairo.Color selection_highlight = CairoExtensions.ColorShade (selection_color, 1.24);
Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
selection_highlight.A = 0.5;
selection_stroke.A = color.A;
if (filled) {
Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.12);
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_light);
grad.AddColorStop (0.4, selection_fill_dark);
grad.AddColorStop (1, selection_fill_light);
cr.Pattern = grad;
CairoExtensions.RoundedRectangle (cr, x, y, width, height, Context.Radius, corners, true);
cr.Fill ();
grad.Destroy ();
}
if (filled && stroked) {
cr.LineWidth = 1.0;
cr.Color = selection_highlight;
CairoExtensions.RoundedRectangle (cr, x + 1.5, y + 1.5, width - 3, height - 3, Context.Radius - 1, corners, true);
cr.Stroke ();
}
if (stroked) {
cr.LineWidth = 1.0;
cr.Color = selection_stroke;
CairoExtensions.RoundedRectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1, Context.Radius, corners, true);
cr.Stroke ();
}
}
示例3: 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.Pattern = grad;
cr.Fill ();
grad.Destroy ();
}
示例4: RenderThumbnail
public static void RenderThumbnail (Cairo.Context cr, ImageSurface image, bool dispose,
double x, double y, double width, double height, bool drawBorder, double radius,
bool fill, Color fillColor, CairoCorners corners)
{
if (image == null || image.Handle == IntPtr.Zero) {
image = null;
}
double p_x = x;
double p_y = y;
if (image != null) {
p_x += image.Width < width ? (width - image.Width) / 2 : 0;
p_y += image.Height < height ? (height - image.Height) / 2 : 0;
}
cr.Antialias = Cairo.Antialias.Default;
if (image != null) {
if (fill) {
CairoExtensions.RoundedRectangle (cr, x, y, width, height, radius, corners);
cr.Color = fillColor;
cr.Fill ();
}
CairoExtensions.RoundedRectangle (cr, p_x, p_y, image.Width, image.Height, radius, corners);
cr.SetSource (image, p_x, p_y);
cr.Fill ();
} else {
CairoExtensions.RoundedRectangle (cr, x, y, width, height, radius, corners);
if (fill) {
var grad = new LinearGradient (x, y, x, y + height);
grad.AddColorStop (0, fillColor);
grad.AddColorStop (1, CairoExtensions.ColorShade (fillColor, 1.3));
cr.Pattern = grad;
cr.Fill ();
grad.Destroy ();
}
Banshee.CairoGlyphs.BansheeLineLogo.Render (cr,
new Rectangle (x + 15, y + 15, width - 30, height - 30),
CairoExtensions.RgbaToColor (0x00000044),
CairoExtensions.RgbaToColor (0x00000055));
}
if (!drawBorder) {
if (dispose && image != null) {
((IDisposable)image).Dispose ();
}
return;
}
cr.LineWidth = 1.0;
if (radius < 1) {
cr.Antialias = Antialias.None;
CairoExtensions.RoundedRectangle (cr, x + 1.5, y + 1.5, width - 3, height - 3, radius, corners);
cr.Color = cover_border_light_color;
cr.Stroke ();
}
CairoExtensions.RoundedRectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1, radius, corners);
cr.Color = cover_border_dark_color;
cr.Stroke ();
if (dispose && image != null) {
((IDisposable)image).Dispose ();
}
}
示例5: OnDrawn
protected override bool OnDrawn(Cairo.Context cr)
{
if (!CairoHelper.ShouldDrawWindow (cr, Window)) {
return base.OnDrawn (cr);
}
if (reflect) {
CairoExtensions.PushGroup (cr);
}
cr.Operator = Operator.Over;
cr.Translate (h_padding, 0);
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.Source = 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.Pattern = 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.Destroy ();
cr.Restore ();
CairoExtensions.PopGroupToSource (cr);
cr.Paint ();
}
if (show_labels) {
cr.Translate ((reflect ? 0 : -h_padding) + (Allocation.Width - layout_width) / 2,
bar_height + bar_label_spacing);
RenderLabels (cr);
}
bar.Destroy ();
return true;
}
示例6: DrawColumnHighlight
public override 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.Pattern = grad;
cr.Rectangle (alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
cr.Fill ();
grad.Destroy ();
}
示例7: ClippedRender
protected override void ClippedRender(Hyena.Data.Gui.CellContext context)
{
if (!EnsureLayout ()) {
return;
}
var cr = context.Context;
context.Theme.Widget.StyleContext.Save ();
if (context.TextAsForeground) {
context.Theme.Widget.StyleContext.AddClass ("button");
} else {
context.Theme.Widget.StyleContext.AddClass ("entry");
}
Foreground = new Brush (context.Theme.Widget.StyleContext.GetColor (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 ();
}
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);
}
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.Destroy ();
}
cr.ResetClip ();
context.Theme.Widget.StyleContext.Restore ();
}
示例8: PaintProgressSurface
void PaintProgressSurface (DockySurface surface)
{
if (Progress <= 0)
return;
double padding = 2.0;
double width = surface.Width - 2 * padding;
double height = Math.Min (26.0, 0.18 * surface.Height);
double x = padding;
double y = surface.Height - height - padding;
double lineSize = 1.0;
surface.Context.LineWidth = lineSize;
// draw the outer stroke
x += lineSize / 2.0;
y += lineSize / 2.0;
width -= lineSize;
height -= lineSize;
LinearGradient outer_stroke = new LinearGradient (0, y, 0, y + height);
outer_stroke.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.3));
outer_stroke.AddColorStop (1, new Cairo.Color (1, 1, 1, 0.3));
DrawRoundedLine (surface, x, y, width, height, true, true, outer_stroke, null);
outer_stroke.Destroy ();
// draw the finished stroke/fill
x += lineSize;
y += lineSize;
width -= 2 * lineSize;
height -= 2 * lineSize;
double finishedWidth = Progress * width - lineSize / 2.0;
LinearGradient finished_stroke = new LinearGradient (0, y, 0, y + height);
finished_stroke.AddColorStop (0, new Cairo.Color (67 / 255.0, 165 / 255.0, 226 / 255.0, 1));
finished_stroke.AddColorStop (1, new Cairo.Color (32 / 255.0, 94 / 255.0, 136 / 255.0, 1));
LinearGradient finished_fill = new LinearGradient (0, y, 0, y + height);
finished_fill.AddColorStop (0, new Cairo.Color (91 / 255.0, 174 / 255.0, 226 / 255.0, 1));
finished_fill.AddColorStop (1, new Cairo.Color (35 / 255.0, 115 / 255.0, 164 / 255.0, 1));
DrawRoundedLine (surface, x, y, finishedWidth, height, true, false, finished_stroke, finished_fill);
finished_stroke.Destroy ();
finished_fill.Destroy ();
// draw the remaining stroke/fill
LinearGradient remaining_stroke = new LinearGradient (0, y, 0, y + height);
remaining_stroke.AddColorStop (0, new Cairo.Color (82 / 255.0, 82 / 255.0, 82 / 255.0, 1));
remaining_stroke.AddColorStop (1, new Cairo.Color (148 / 255.0, 148 / 255.0, 148 / 255.0, 1));
LinearGradient remaining_fill = new LinearGradient (0, y, 0, y + height);
remaining_fill.AddColorStop (0, new Cairo.Color (106 / 255.0, 106 / 255.0, 106 / 255.0, 1));
remaining_fill.AddColorStop (1, new Cairo.Color (159 / 255.0, 159 / 255.0, 159 / 255.0, 1));
DrawRoundedLine (surface, x + finishedWidth + lineSize, y, width - finishedWidth, height, false, true, remaining_stroke, remaining_fill);
remaining_stroke.Destroy ();
remaining_fill.Destroy ();
// draw the highlight on the finished part
x += lineSize;
y += lineSize;
width -= lineSize;
height -= 2 * lineSize;
LinearGradient finished_highlight = new LinearGradient (0, y, 0, y + height);
finished_highlight.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.3));
finished_highlight.AddColorStop (0.2, new Cairo.Color (1, 1, 1, 0));
DrawRoundedLine (surface, x, y, finishedWidth, height, true, false, finished_highlight, null);
finished_highlight.Destroy ();
}
示例9: DrawApplicationMenu
internal void DrawApplicationMenu(Context cr, Rectangle r, Gdk.Rectangle itemsAlloc, double lineWidth, ApplicationMenu w)
{
double lineWidth05 = lineWidth / 2;
double lineWidth15 = lineWidth * 1.5;
Gdk.Rectangle alloc = w.Allocation;
cr.Color = new Color (0.4, 0.4, 0.4);
cr.Paint ();
cr.Rectangle (itemsAlloc.X, itemsAlloc.Y, itemsAlloc.Width, itemsAlloc.Height);
cr.Color = new Color (0.9216, 0.9216, 0.9216);
cr.Fill ();
cr.LineWidth = lineWidth;
cr.MoveTo (itemsAlloc.Right - lineWidth05, itemsAlloc.Top);
cr.LineTo (itemsAlloc.Right - lineWidth05, itemsAlloc.Bottom);
cr.Color = new Color (1, 1, 1, 0.2);
cr.Stroke ();
cr.MoveTo (itemsAlloc.Right - lineWidth15, itemsAlloc.Top);
cr.LineTo (itemsAlloc.Right - lineWidth15, itemsAlloc.Bottom);
cr.Color = new Color (0, 0, 0, 0.2);
cr.Stroke ();
cr.Rectangle (alloc.X, alloc.Y, alloc.Width, itemsAlloc.Y - alloc.Y);
LinearGradient linGrad = new LinearGradient (0, alloc.Y, 0, itemsAlloc.Y - alloc.Y);
linGrad.AddColorStop (0.0, new Color (0.4, 0.4, 0.4));
linGrad.AddColorStop (0.3, new Color (0.2, 0.2, 0.2));
linGrad.AddColorStop (0.3, new Color (0, 0, 0));
linGrad.AddColorStop (1.0, new Color (0.4, 0.4, 0.4));
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();
cr.Rectangle (alloc.X, itemsAlloc.Bottom, alloc.Width, alloc.Bottom - itemsAlloc.Bottom);
linGrad = new LinearGradient (0, itemsAlloc.Bottom, 0, alloc.Bottom);
linGrad.AddColorStop (0.0, new Color (0.4, 0.4, 0.4));
linGrad.AddColorStop (0.3, new Color (0.2, 0.2, 0.2));
linGrad.AddColorStop (0.3, new Color (0, 0, 0));
linGrad.AddColorStop (1.0, new Color (0.4, 0.4, 0.4));
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();
Gdk.Rectangle appBtnAlloc = w.ApplicationButton.Allocation;
appBtnAlloc.X = alloc.X;
appBtnAlloc.Y = itemsAlloc.Y - 2 - appBtnAlloc.Height;
DrawApplicationButton (cr, appBtnAlloc, ButtonState.Pressed, 1.0, w.ApplicationButton);
}
示例10: DrawTile
/// <summary>Draws a tile.</summary>
public void DrawTile(Context cr, Rectangle bodyAllocation, Rectangle contentAllocation, Tile widget)
{
if(widget.Selected)
{
LinearGradient grad = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
grad.AddColorStop (0.00, new Color (0.9922, 0.7373, 0.4353));
grad.AddColorStop (0.27, new Color (0.9961, 0.8039, 0.5569));
grad.AddColorStop (0.33, new Color (0.9961, 0.7255, 0.4078));
grad.AddColorStop (1.00, new Color (0.9843, 0.8980, 0.6313));
cr.Pattern = grad;
cr.Rectangle (bodyAllocation);
cr.Fill ();
grad.Destroy ();
}
cr.Color = new Color (1, 1, 1);
cr.Rectangle (contentAllocation);
cr.Fill ();
}
示例11: DrawApplicationButton
/// <summary>Draws an application button.</summary>
public void DrawApplicationButton(Context cr, Gdk.Rectangle bodyAllocation, ButtonState state, double lineWidth, BaseButton widget)
{
const double dropShadowOffset = 1;
double radius = (bodyAllocation.Height - dropShadowOffset) / 2;
double x = bodyAllocation.X + radius + dropShadowOffset;
double y = bodyAllocation.Y + radius + dropShadowOffset;
cr.Arc (x, y, radius, 0, 2 * Math.PI);
cr.Color = new Color (0, 0, 0, 0.5);
cr.Fill ();
cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI);
switch(state)
{
case ButtonState.Hover:
cr.Color = new Color (0.9, 0.815, 0.533);
break;
case ButtonState.Pressed:
cr.Color = new Color (0.886, 0.639, 0.356);
break;
default:
cr.Color = new Color (0.8, 0.8, 0.8);
break;
}
cr.Fill ();
cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI);
LinearGradient linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + bodyAllocation.Height);
linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.9));
linGrad.AddColorStop (0.5, new Color (1, 1, 1, 0.0));
linGrad.AddColorStop (1.0, new Color (1, 1, 1, 1.0));
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();
cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI);
linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + bodyAllocation.Height);
linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0));
linGrad.AddColorStop (0.4, new Color (0, 0, 0, 0.0));
linGrad.AddColorStop (0.5, new Color (0, 0, 0, 0.1));
linGrad.AddColorStop (0.75, new Color (0, 0, 0, 0.0));
linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.0));
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();
cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, Math.PI);
linGrad = new LinearGradient (0, bodyAllocation.Y + radius, 0, bodyAllocation.Y + bodyAllocation.Height);
linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0));
linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.5));
cr.Pattern = linGrad;
cr.LineWidth = 1.0;
cr.Stroke ();
linGrad.Destroy ();
cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, Math.PI, 0);
linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + radius);
linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.5));
linGrad.AddColorStop (1.0, new Color (1, 1, 1, 0.0));
cr.LineWidth = 1.0;
cr.Stroke ();
linGrad.Destroy ();
cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI);
RadialGradient radGrad = new RadialGradient (bodyAllocation.X + radius, bodyAllocation.Y + 1.5 * radius, 0, bodyAllocation.X + radius, bodyAllocation.Y + 1.5 * radius, 0.5 * radius);
radGrad.AddColorStop (0, new Color (1, 1, 1, 0.4));
radGrad.AddColorStop (1, new Color (1, 1, 1, 0.0));
cr.Pattern = radGrad;
cr.Fill ();
radGrad.Destroy ();
}
示例12: 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;
//.........这里部分代码省略.........
示例13: DrawButton
/// <summary>Draws a button.</summary>
public void DrawButton(Context cr, Rectangle bodyAllocation, ButtonState state, double roundSize, double lineWidth, double arrowSize, double arrowPadding, bool drawSeparator, BaseButton widget)
{
double lineWidth05 = lineWidth / 2;
double lineWidth15 = lineWidth05 * 3;
bool upLeft = true, upRight = true, downRight = true, downLeft = true;
switch(widget.GroupStyle)
{
case GroupStyle.Left:
upRight = downRight = false;
break;
case GroupStyle.Center:
upLeft = downLeft = upRight = downRight = false;
break;
case GroupStyle.Right:
upLeft = downLeft = false;
break;
}
cr.LineWidth = lineWidth;
if(state == ButtonState.Pressed || state == ButtonState.Hover)
{
LinearGradient bodyPattern, innerBorderPattern;
Color borderColor;
if(state == ButtonState.Pressed)
{
bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
bodyPattern.AddColorStopRgb (0.0, new Color (0.996, 0.847, 0.667));
bodyPattern.AddColorStopRgb (0.37, new Color (0.984, 0.710, 0.396));
bodyPattern.AddColorStopRgb (0.43, new Color (0.980, 0.616, 0.204));
bodyPattern.AddColorStopRgb (1.0, new Color (0.992, 0.933, 0.667));
innerBorderPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height);
innerBorderPattern.AddColorStop (0.0, new Color (0.876, 0.718, 0.533, 1));
innerBorderPattern.AddColorStop (1.0, new Color (0.876, 0.718, 0.533, 0));
borderColor = new Color (0.671, 0.631, 0.549);
}
else
{
bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
bodyPattern.AddColorStopRgb (0.0, new Color (1, 0.996, 0.890));
bodyPattern.AddColorStopRgb (0.37, new Color (1, 0.906, 0.592));
bodyPattern.AddColorStopRgb (0.43, new Color (1, 0.843, 0.314));
bodyPattern.AddColorStopRgb (1.0, new Color (1, 0.906, 0.588));
innerBorderPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height);
innerBorderPattern.AddColorStop (0.0, new Color (1, 1, 0.969, 1));
innerBorderPattern.AddColorStop (1.0, new Color (1, 1, 0.969, 0));
borderColor = new Color (0.824, 0.753, 0.553);
}
double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05;
double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05;
if(upLeft) cr.MoveTo (x0 + roundSize, y0);
else cr.MoveTo (x0, y0);
if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0);
else cr.LineTo (x1, y0);
if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI);
else cr.LineTo (x1, y1);
if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI);
else cr.LineTo (x0, y1);
if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI);
else cr.LineTo (x0, y0);
cr.Pattern = bodyPattern;
cr.Fill ();
bodyPattern.Destroy ();
x0 = bodyAllocation.X + lineWidth15; y0 = bodyAllocation.Y + lineWidth15;
x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth15; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth15;
double roundSizeMinusLineWidth = roundSize - lineWidth;
if(widget.GroupStyle != GroupStyle.Left) x0 -= lineWidth;
if(upLeft) cr.MoveTo (x0 + roundSizeMinusLineWidth, y0);
else cr.MoveTo (x0, y0);
if(upRight) cr.Arc (x1 - roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, 1.5*Math.PI, 0);
else cr.LineTo (x1, y0);
if(downRight) cr.Arc (x1 - roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0, 0.5*Math.PI);
else cr.LineTo (x1, y1);
if(downLeft) cr.Arc (x0 + roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0.5*Math.PI, Math.PI);
else cr.LineTo (x0, y1);
if(upLeft) cr.Arc (x0 + roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, Math.PI, 1.5*Math.PI);
else cr.LineTo (x0, y0);
if(widget.GroupStyle != GroupStyle.Left) x0 += lineWidth;
cr.Pattern = innerBorderPattern;
cr.Stroke ();
innerBorderPattern.Destroy ();
x0 = bodyAllocation.X + lineWidth05; y0 = bodyAllocation.Y + lineWidth05;
x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05;
//.........这里部分代码省略.........
示例14: ClippedRender
protected override void ClippedRender(Context cr)
{
if (!EnsureLayout ()) {
return;
}
Brush foreground = Foreground;
if (!foreground.IsValid) {
return;
}
cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
cr.Clip ();
bool fade = text_alloc.Width > RenderSize.Width;
if (fade) {
cr.PushGroup ();
}
cr.MoveTo (text_alloc.X, text_alloc.Y);
Foreground.Apply (cr);
Pango.CairoHelper.ShowLayout (cr, layout);
cr.Fill ();
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.Destroy ();
}
cr.ResetClip ();
}
示例15: PaintIconSurface
protected override void PaintIconSurface (DockySurface surface)
{
if (DeskGrid == null)
return;
int cols = DeskGrid.GetLength (0);
int rows = DeskGrid.GetLength (1);
Gdk.Color gdkColor = Style.Backgrounds [(int) Gtk.StateType.Selected];
Cairo.Color selection_color = new Cairo.Color ((double) gdkColor.Red / ushort.MaxValue,
(double) gdkColor.Green / ushort.MaxValue,
(double) gdkColor.Blue / ushort.MaxValue,
0.5);
Context cr = surface.Context;
cr.AlphaPaint ();
LinearGradient lg = new LinearGradient (0, 0, 0, surface.Height);
lg.AddColorStop (0, new Cairo.Color (.35, .35, .35, .6));
lg.AddColorStop (1, new Cairo.Color (.05, .05, .05, .7));
for (int x = 0; x < cols; x++) {
for (int y = 0; y < rows; y++) {
if (DeskGrid[x,y] != null) {
Cairo.Rectangle area = DeskAreaOnIcon (surface.Width, surface.Height, x, y);
cr.Rectangle (area.X, area.Y, area.Width, area.Height);
cr.Pattern = lg;
cr.FillPreserve ();
if (DeskGrid[x,y].IsActive) {
cr.Color = selection_color;
cr.Fill ();
if (area.Width >= 16 && area.Height >= 16) {
using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon ("desktop", (int) area.Width, (int) area.Height)) {
Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, (int) area.X + (area.Width - pbuf.Width) / 2, (int) area.Y + (area.Height - pbuf.Height) / 2);
cr.Paint ();
}
}
}
cr.NewPath ();
}
}
}
lg.Destroy ();
for (int x = 0; x < cols; x++) {
for (int y = 0; y < rows; y++) {
if (DeskGrid[x,y] != null) {
Cairo.Rectangle area = DeskAreaOnIcon (surface.Width, surface.Height, x, y);
cr.Rectangle (area.X, area.Y, area.Width, area.Height);
}
}
}
lg = new LinearGradient (0, 0, 0, surface.Height);
lg.AddColorStop (0, new Cairo.Color (.95, .95, .95, .7));
lg.AddColorStop (1, new Cairo.Color (.5, .5, .5, .7));
cr.Pattern = lg;
cr.StrokePreserve ();
lg.Destroy ();
}