protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (!pulsator.IsPulsing) { return(base.OnExposeEvent(evnt)); } Cairo.Context cr = Gdk.CairoHelper.Create(GdkWindow); double x = Allocation.X + Allocation.Width / 2; double y = Allocation.Y + Allocation.Height / 2; double r = Math.Min(Allocation.Width, Allocation.Height) / 2; double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine); var color = CairoExtensions.GdkColorToCairoColor(Style.Background(StateType.Selected)); var fill = new Cairo.RadialGradient(x, y, 0, x, y, r); color.A = alpha; fill.AddColorStop(0, color); fill.AddColorStop(0.5, color); color.A = 0; fill.AddColorStop(1, color); cr.Arc(x, y, r, 0, 2 * Math.PI); cr.SetSource(fill); cr.Fill(); fill.Dispose(); CairoExtensions.DisposeContext(cr); return(base.OnExposeEvent(evnt)); }
public static void Gradient (Cairo.Context cr, Theme theme, Rect rect, double opacity) { cr.Save (); cr.Translate (rect.X, rect.Y); var x = rect.Width / 2.0; var y = rect.Height / 2.0; var grad = new Cairo.RadialGradient (x, y, 0, x, y, rect.Width / 2.0); grad.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.1 * opacity)); grad.AddColorStop (1, new Cairo.Color (0, 0, 0, 0.35 * opacity)); cr.SetSource (grad); CairoExtensions.RoundedRectangle (cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius); cr.Fill (); grad.Dispose (); cr.Restore (); }
public static void Gradient(Cairo.Context cr, Theme theme, Rect rect, double opacity) { cr.Save(); cr.Translate(rect.X, rect.Y); var x = rect.Width / 2.0; var y = rect.Height / 2.0; var grad = new Cairo.RadialGradient(x, y, 0, x, y, rect.Width / 2.0); grad.AddColorStop(0, new Cairo.Color(0, 0, 0, 0.1 * opacity)); grad.AddColorStop(1, new Cairo.Color(0, 0, 0, 0.35 * opacity)); cr.SetSource(grad); CairoExtensions.RoundedRectangle(cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius); cr.Fill(); grad.Dispose(); cr.Restore(); }
protected override bool OnExposeEvent (Gdk.EventExpose evnt) { if (!pulsator.IsPulsing) { return base.OnExposeEvent (evnt); } Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow); double x = Allocation.X + Allocation.Width / 2; double y = Allocation.Y + Allocation.Height / 2; double r = Math.Min (Allocation.Width, Allocation.Height) / 2; double alpha = Choreographer.Compose (pulsator.Percent, Easing.Sine); Cairo.Color color = CairoExtensions.GdkColorToCairoColor (Style.Background (StateType.Selected)); Cairo.RadialGradient fill = new Cairo.RadialGradient (x, y, 0, x, y, r); color.A = alpha; fill.AddColorStop (0, color); fill.AddColorStop (0.5, color); color.A = 0; fill.AddColorStop (1, color); cr.Arc (x, y, r, 0, 2 * Math.PI); cr.SetSource (fill); cr.Fill (); fill.Dispose (); CairoExtensions.DisposeContext (cr); return base.OnExposeEvent (evnt); }