本文整理汇总了C#中Cairo.LinearGradient类的典型用法代码示例。如果您正苦于以下问题:C# LinearGradient类的具体用法?C# LinearGradient怎么用?C# LinearGradient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LinearGradient类属于Cairo命名空间,在下文中一共展示了LinearGradient类的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: Render
protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
{
using (Cairo.Context gr = Gdk.CairoHelper.Create (window)) {
gr.Rectangle (cell_area.X, cell_area.Y, cell_area.Width, cell_area.Height);
gr.Color = (HslColor)widget.Style.Base ((flags & CellRendererState.Selected) == CellRendererState.Selected ? StateType.Selected : StateType.Normal);
gr.Fill ();
var size = Math.Max (0, cell_area.Width - cell_area.Width * Time / 100.0);
var linearGradient = new LinearGradient (cell_area.X, cell_area.Y, cell_area.Right, cell_area.Bottom);
linearGradient.AddColorStop (0, new Cairo.Color (1, 0, 0));
linearGradient.AddColorStop (1, new Cairo.Color (1, 1, 1));
gr.Pattern = linearGradient;
gr.Rectangle (cell_area.X + size, cell_area.Y + 2, cell_area.Width - size, cell_area.Height - 4);
gr.Fill ();
var layout = gr.CreateLayout ();
layout.FontDescription = widget.PangoContext.FontDescription;
layout.SetText (string.Format ("{0:0.0}", Time));
int w, h;
layout.GetPixelSize (out w, out h);
gr.MoveTo (cell_area.X + cell_area.Width - 2 - w, cell_area.Y + (cell_area.Height - h) / 2);
gr.Color = new Cairo.Color (0, 0, 0);
gr.ShowLayout (layout);
layout.Dispose ();
}
}
示例3: 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 ();
}
示例4: Render
public override void Render(Context cr)
{
if (!CanResize) {
return;
}
var selected_color = CairoExtensions.GdkColorToCairoColor (Window.Style.Dark (StateType.Active));
var grad = new LinearGradient (0, 0, 0, Allocation.Height);
selected_color.A = 0.4;
grad.AddColorStop (0, selected_color);
selected_color.A = 1.0;
grad.AddColorStop (1, selected_color);
cr.Pattern = grad;
cr.LineWidth = 1.0;
cr.Rectangle (0.5, 0.5, Allocation.Width - 1, Allocation.Height - 1);
cr.Stroke ();
selected_color.A = 0.5;
cr.Color = selected_color;
double handle_size = 8;
double ty = 0.5 + Allocation.Height - handle_size - 3;
double tx = 0.5 + (Window.Direction == TextDirection.Ltr
? Allocation.Width - handle_size - 3
: 3);
cr.Translate (tx, ty);
for (double i = 0; i < 3; i++) {
if (Window.Direction == TextDirection.Ltr) {
cr.MoveTo (i * 3, handle_size);
cr.LineTo (handle_size, i * 3);
} else {
cr.MoveTo (0, i * 3);
cr.LineTo (handle_size - i * 3, handle_size);
}
}
cr.Stroke ();
cr.Translate (-tx, -ty);
}
示例5: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
Pango.Layout la = new Pango.Layout (PangoContext);
int w, h;
if (UseMarkup)
la.SetMarkup (Text);
else
la.SetText (Text);
la.GetPixelSize (out w, out h);
int tx = Allocation.X + (int) Xpad + (int) ((float)(Allocation.Width - (int)(Xpad*2) - w) * Xalign);
int ty = Allocation.Y + (int) Ypad + (int) ((float)(Allocation.Height - (int)(Ypad*2) - h) * Yalign);
using (var ctx = CairoHelper.Create (evnt.Window)) {
ctx.SetSourceColor (Style.Text (State).ToCairoColor ());
ctx.MoveTo (tx, ty);
// In order to get the same result as in MonoDevelop.Components.DockNotebook.TabStrip.DrawTab()
// (document tabs) we need to draw using a LinearGradient (because of issues below),
// but we don't want to mask the actual text here, like in the doc tabs.
// Therefore we use a LinearGradient and mask only the last vertical pixel line
// of the label with 0.99 alpha, which forces Cairo to render the whole layout
// in the desired way.
// Semi-transparent gradient disables sub-pixel rendering of the label (reverting to grayscale antialiasing).
// As Mac sub-pixel font rendering looks stronger than grayscale rendering, the label used in pad tabs
// looked different. We need to simulate same gradient treatment as we have in document tabs.
using (var lg = new LinearGradient (tx + w - 1, 0, tx + w, 0)) {
var color = Style.Text (State).ToCairoColor ();
lg.AddColorStop (0, color);
color.A = 0.99;
lg.AddColorStop (1, color);
ctx.SetSource (lg);
Pango.CairoHelper.ShowLayout (ctx, la);
}
}
la.Dispose ();
return true;
}
示例6: Render
public void Render (Cairo.Context context, StatusArea.RenderArg arg)
{
context.CachedDraw (surface: ref backgroundSurface,
region: arg.Allocation,
draw: (c, o) => DrawBackground (c, new Gdk.Rectangle (0, 0, arg.Allocation.Width, arg.Allocation.Height)));
if (arg.BuildAnimationOpacity > 0.001f)
DrawBuildEffect (context, arg.Allocation, arg.BuildAnimationProgress, arg.BuildAnimationOpacity);
if (arg.ErrorAnimationProgress > 0.001 && arg.ErrorAnimationProgress < .999) {
DrawErrorAnimation (context, arg);
}
DrawBorder (context, arg.Allocation);
if (arg.HoverProgress > 0.001f)
{
context.Clip ();
int x1 = arg.Allocation.X + arg.MousePosition.X - 200;
int x2 = x1 + 400;
using (Cairo.LinearGradient gradient = new LinearGradient (x1, 0, x2, 0))
{
Cairo.Color targetColor = Styles.StatusBarFill1Color;
Cairo.Color transparentColor = targetColor;
targetColor.A = .7;
transparentColor.A = 0;
targetColor.A = .7 * arg.HoverProgress;
gradient.AddColorStop (0.0, transparentColor);
gradient.AddColorStop (0.5, targetColor);
gradient.AddColorStop (1.0, transparentColor);
context.Pattern = gradient;
context.Rectangle (x1, arg.Allocation.Y, x2 - x1, arg.Allocation.Height);
context.Fill ();
}
context.ResetClip ();
} else {
context.NewPath ();
}
int progress_bar_x = arg.ChildAllocation.X;
int progress_bar_width = arg.ChildAllocation.Width;
if (arg.CurrentPixbuf != null) {
int y = arg.Allocation.Y + (arg.Allocation.Height - arg.CurrentPixbuf.Height) / 2;
Gdk.CairoHelper.SetSourcePixbuf (context, arg.CurrentPixbuf, arg.ChildAllocation.X, y);
context.Paint ();
progress_bar_x += arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
progress_bar_width -= arg.CurrentPixbuf.Width + Styles.ProgressBarOuterPadding;
}
int center = arg.Allocation.Y + arg.Allocation.Height / 2;
Gdk.Rectangle progressArea = new Gdk.Rectangle (progress_bar_x, center - Styles.ProgressBarHeight / 2, progress_bar_width, Styles.ProgressBarHeight);
if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0) {
DrawProgressBar (context, arg.ProgressBarFraction, progressArea, arg);
ClipProgressBar (context, progressArea);
}
int text_x = progress_bar_x + Styles.ProgressBarInnerPadding;
int text_width = progress_bar_width - (Styles.ProgressBarInnerPadding * 2);
double textTweenValue = arg.TextAnimationProgress;
if (arg.LastText != null) {
double opacity = Math.Max (0.0f, 1.0f - textTweenValue);
DrawString (arg.LastText, arg.LastTextIsMarkup, context, text_x,
center - (int)(textTweenValue * arg.Allocation.Height * 0.3), text_width, opacity, arg.Pango, arg);
}
if (arg.CurrentText != null) {
DrawString (arg.CurrentText, arg.CurrentTextIsMarkup, context, text_x,
center + (int)((1.0f - textTweenValue) * arg.Allocation.Height * 0.3), text_width, Math.Min (textTweenValue, 1.0), arg.Pango, arg);
}
if (arg.ShowProgressBar || arg.ProgressBarAlpha > 0)
context.ResetClip ();
}
示例7: DrawBackground
protected virtual void DrawBackground (Cairo.Context context, Gdk.Rectangle region)
{
LayoutRoundedRectangle (context, region);
context.ClipPreserve ();
using (LinearGradient lg = new LinearGradient (region.X, region.Y, region.X, region.Y + region.Height)) {
lg.AddColorStop (0, Styles.StatusBarFill1Color);
lg.AddColorStop (1, Styles.StatusBarFill4Color);
context.Pattern = lg;
context.FillPreserve ();
}
context.Save ();
double midX = region.X + region.Width / 2.0;
double midY = region.Y + region.Height;
context.Translate (midX, midY);
using (RadialGradient rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) {
rg.AddColorStop (0, Styles.StatusBarFill1Color);
rg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarFill1Color, 0));
context.Scale (region.Width / (double)region.Height, 1.0);
context.Pattern = rg;
context.Fill ();
}
context.Restore ();
using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) {
lg.AddColorStop (0, Styles.StatusBarShadowColor1);
lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor1, Styles.StatusBarShadowColor1.A * 0.2));
LayoutRoundedRectangle (context, region, 0, -1);
context.LineWidth = 1;
context.Pattern = lg;
context.Stroke ();
}
using (LinearGradient lg = new LinearGradient (0, region.Y, 0, region.Y + region.Height)) {
lg.AddColorStop (0, Styles.StatusBarShadowColor2);
lg.AddColorStop (1, Styles.WithAlpha (Styles.StatusBarShadowColor2, Styles.StatusBarShadowColor2.A * 0.2));
LayoutRoundedRectangle (context, region, 0, -2);
context.LineWidth = 1;
context.Pattern = lg;
context.Stroke ();
}
context.ResetClip ();
}
示例8: DrawBackground
void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
{
double rad = radius - 0.5;
int centerX = region.X + region.Width / 2;
int centerY = region.Y + region.Height / 2;
context.MoveTo (centerX + rad, centerY);
context.Arc (centerX, centerY, rad, 0, Math.PI * 2);
double high;
double low;
switch (state) {
case StateType.Selected:
high = 0.85;
low = 1.0;
break;
case StateType.Prelight:
high = 1.0;
low = 0.9;
break;
case StateType.Insensitive:
high = 0.95;
low = 0.83;
break;
default:
high = 1.0;
low = 0.85;
break;
}
using (var lg = new LinearGradient (0, centerY - rad, 0, centerY +rad)) {
lg.AddColorStop (0, new Cairo.Color (high, high, high));
lg.AddColorStop (1, new Cairo.Color (low, low, low));
context.SetSource (lg);
context.FillPreserve ();
}
context.SetSourceRGBA (0, 0, 0, 0.4);
context.LineWidth = 1;
context.Stroke ();
}
示例9: DrawRowSelection
public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
bool filled, bool stroked, Cairo.Color color, CairoCorners corners, bool flat_fill)
{
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;
LinearGradient grad = null;
if (filled) {
if (flat_fill) {
cr.Color = selection_color;
} else {
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;
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 ();
if (grad != null) {
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 ();
}
}
示例10: PaintSurface
protected sealed override void PaintSurface (DockySurface surface)
{
surface.Clear ();
lock (buffers) {
if (slideCounter > 0 && slideCounter < slideSteps) {
double offset = Allocation.Width * Math.Log (slideCounter) / Math.Log (slideSteps);
if (MovedLeft) {
ShowBuffer (surface, Page, offset - Allocation.Width);
ShowBuffer (surface, LastPage, offset);
} else {
ShowBuffer (surface, Page, Allocation.Width - offset);
ShowBuffer (surface, LastPage, -offset);
}
// fade out the edges during a slide
Gradient linpat = new LinearGradient (0, surface.Height / 2, surface.Width, surface.Height / 2);
linpat.AddColorStop (0, new Color(1, 1, 1, 1));
linpat.AddColorStop (2 * (double) BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
linpat.AddColorStop (1 - 2 * (double) BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
linpat.AddColorStop (1, new Color(1, 1, 1, 1));
surface.Context.Save ();
surface.Context.Operator = Operator.Source;
surface.Context.Color = new Cairo.Color (0, 0, 0, 0);
surface.Context.Mask (linpat);
surface.Context.PaintWithAlpha (0);
surface.Context.Restore ();
linpat.Destroy ();
} else {
ShowBuffer (surface, Page, 0);
}
}
// overlay the prev/next arrow buttons
if (buttonBuffer != null && (buttonBuffer.Width != surface.Width || buttonBuffer.Height != surface.Height))
ResetButtons ();
if (buttonBuffer == null) {
buttonBuffer = new DockySurface (surface.Width, surface.Height, surface);
DrawButtonsBuffer ();
}
buttonBuffer.Internal.Show (surface.Context, 0, 0);
}
示例11: RenderOuterShadow
// VERY SLOW, only use on cached renders
public static void RenderOuterShadow (this Cairo.Context self, Gdk.Rectangle area, int size, int rounding, double strength)
{
area.Inflate (-1, -1);
size++;
int doubleRounding = rounding * 2;
// left side
self.Rectangle (area.X - size, area.Y + rounding, size, area.Height - doubleRounding - 1);
using (var lg = new LinearGradient (area.X, 0, area.X - size, 0)) {
ShadowGradient (lg, strength);
self.Pattern = lg;
self.Fill ();
}
// right side
self.Rectangle (area.Right, area.Y + rounding, size, area.Height - doubleRounding - 1);
using (var lg = new LinearGradient (area.Right, 0, area.Right + size, 0)) {
ShadowGradient (lg, strength);
self.Pattern = lg;
self.Fill ();
}
// top side
self.Rectangle (area.X + rounding, area.Y - size, area.Width - doubleRounding - 1, size);
using (var lg = new LinearGradient (0, area.Y, 0, area.Y - size)) {
ShadowGradient (lg, strength);
self.Pattern = lg;
self.Fill ();
}
// bottom side
self.Rectangle (area.X + rounding, area.Bottom, area.Width - doubleRounding - 1, size);
using (var lg = new LinearGradient (0, area.Bottom, 0, area.Bottom + size)) {
ShadowGradient (lg, strength);
self.Pattern = lg;
self.Fill ();
}
// top left corner
self.Rectangle (area.X - size, area.Y - size, size + rounding, size + rounding);
using (var rg = new RadialGradient (area.X + rounding, area.Y + rounding, rounding, area.X + rounding, area.Y + rounding, size + rounding)) {
ShadowGradient (rg, strength);
self.Pattern = rg;
self.Fill ();
}
// top right corner
self.Rectangle (area.Right - rounding, area.Y - size, size + rounding, size + rounding);
using (var rg = new RadialGradient (area.Right - rounding, area.Y + rounding, rounding, area.Right - rounding, area.Y + rounding, size + rounding)) {
ShadowGradient (rg, strength);
self.Pattern = rg;
self.Fill ();
}
// bottom left corner
self.Rectangle (area.X - size, area.Bottom - rounding, size + rounding, size + rounding);
using (var rg = new RadialGradient (area.X + rounding, area.Bottom - rounding, rounding, area.X + rounding, area.Bottom - rounding, size + rounding)) {
ShadowGradient (rg, strength);
self.Pattern = rg;
self.Fill ();
}
// bottom right corner
self.Rectangle (area.Right - rounding, area.Bottom - rounding, size + rounding, size + rounding);
using (var rg = new RadialGradient (area.Right - rounding, area.Bottom - rounding, rounding, area.Right - rounding, area.Bottom - rounding, size + rounding)) {
ShadowGradient (rg, strength);
self.Pattern = rg;
self.Fill ();
}
}
示例12: 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 ();
}
示例13: 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 ();
}
}
示例14: Draw
void Draw(Cairo.Context ctx, List<TableRow> rowList, int dividerX, int x, ref int y)
{
if (!heightMeasured)
return;
Pango.Layout layout = new Pango.Layout (PangoContext);
TableRow lastCategory = null;
foreach (var r in rowList) {
int w,h;
layout.SetText (r.Label);
layout.GetPixelSize (out w, out h);
int indent = 0;
if (r.IsCategory) {
var rh = h + CategoryTopBottomPadding*2;
ctx.Rectangle (0, y, Allocation.Width, rh);
using (var gr = new LinearGradient (0, y, 0, rh)) {
gr.AddColorStop (0, new Cairo.Color (248d/255d, 248d/255d, 248d/255d));
gr.AddColorStop (1, new Cairo.Color (240d/255d, 240d/255d, 240d/255d));
ctx.SetSource (gr);
ctx.Fill ();
}
if (lastCategory == null || lastCategory.Expanded || lastCategory.AnimatingExpand) {
ctx.MoveTo (0, y + 0.5);
ctx.LineTo (Allocation.Width, y + 0.5);
}
ctx.MoveTo (0, y + rh - 0.5);
ctx.LineTo (Allocation.Width, y + rh - 0.5);
ctx.SetSourceColor (DividerColor);
ctx.Stroke ();
ctx.MoveTo (x, y + CategoryTopBottomPadding);
ctx.SetSourceColor (CategoryLabelColor);
Pango.CairoHelper.ShowLayout (ctx, layout);
var img = r.Expanded ? discloseUp : discloseDown;
ctx.DrawImage (this, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y + Math.Round ((rh - img.Height) / 2));
y += rh;
lastCategory = r;
}
else {
var cell = GetCell (r);
r.Enabled = !r.Property.IsReadOnly || cell.EditsReadOnlyObject;
var state = r.Enabled ? State : Gtk.StateType.Insensitive;
ctx.Save ();
ctx.Rectangle (0, y, dividerX, h + PropertyTopBottomPadding*2);
ctx.Clip ();
ctx.MoveTo (x, y + PropertyTopBottomPadding);
ctx.SetSourceColor (Style.Text (state).ToCairoColor ());
Pango.CairoHelper.ShowLayout (ctx, layout);
ctx.Restore ();
if (r != currentEditorRow)
cell.Render (GdkWindow, ctx, r.EditorBounds, state);
y += r.EditorBounds.Height;
indent = PropertyIndent;
}
if (r.ChildRows != null && r.ChildRows.Count > 0 && (r.Expanded || r.AnimatingExpand)) {
int py = y;
ctx.Save ();
if (r.AnimatingExpand)
ctx.Rectangle (0, y, Allocation.Width, r.AnimationHeight);
else
ctx.Rectangle (0, 0, Allocation.Width, Allocation.Height);
ctx.Clip ();
Draw (ctx, r.ChildRows, dividerX, x + indent, ref y);
ctx.Restore ();
if (r.AnimatingExpand) {
y = py + r.AnimationHeight;
// Repaing the background because the cairo clip doesn't work for gdk primitives
int dx = (int)((double)Allocation.Width * dividerPosition);
ctx.Rectangle (0, y, dx, Allocation.Height - y);
ctx.SetSourceColor (LabelBackgroundColor);
ctx.Fill ();
ctx.Rectangle (dx + 1, y, Allocation.Width - dx - 1, Allocation.Height - y);
ctx.SetSourceRGB (1, 1, 1);
ctx.Fill ();
}
}
}
}
示例15: CreateScene
private Surface CreateScene (Cairo.Context window_cr, ImageSurface image, int reflect)
{
Surface surface = window_cr.Target.CreateSimilar (window_cr.Target.Content,
image.Width, image.Height + reflect);
Cairo.Context cr = new Context (surface);
cr.Save ();
cr.SetSource (image);
cr.Paint ();
cr.Rectangle (0, image.Height, image.Width, reflect);
cr.Clip ();
Matrix matrix = new Matrix ();
matrix.InitScale (1, -1);
matrix.Translate (0, -(2 * image.Height) + 1);
cr.Transform (matrix);
cr.SetSource (image);
cr.Paint ();
cr.Restore ();
Color bg_transparent = BackgroundColor;
bg_transparent.A = 0.65;
LinearGradient mask = new LinearGradient (0, image.Height, 0, image.Height + reflect);
mask.AddColorStop (0, bg_transparent);
mask.AddColorStop (1, BackgroundColor);
cr.Rectangle (0, image.Height, image.Width, reflect);
cr.Pattern = mask;
cr.Fill ();
((IDisposable)cr).Dispose ();
return surface;
}