コード例 #1
0
ファイル: PulsingButton.cs プロジェクト: knocte/hyena
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!pulsator.IsPulsing)
            {
                return(base.OnDrawn(cr));
            }

            double x     = Allocation.Width / 2;
            double y     = Allocation.Height / 2;
            double r     = Math.Min(Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose(pulsator.Percent, Easing.Sine);

            Gdk.RGBA             rgba  = StyleContext.GetBackgroundColor(StateFlags.Selected);
            Cairo.Color          color = CairoExtensions.GdkRGBAToCairoColor(rgba);
            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.Pattern = fill;
            cr.Fill();
            fill.Destroy();

            return(base.OnDrawn(cr));
        }
コード例 #2
0
        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.Pattern = fill;
            cr.Fill();
            fill.Destroy();

            CairoExtensions.DisposeContext(cr);
            return(base.OnExposeEvent(evnt));
        }
コード例 #3
0
ファイル: Prelight.cs プロジェクト: fatman2021/gnome-apps
        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.Pattern = grad;
            CairoExtensions.RoundedRectangle (cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius);
            cr.Fill ();
            grad.Destroy ();

            cr.Restore ();
        }
コード例 #4
0
        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.Pattern = grad;
            CairoExtensions.RoundedRectangle(cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius);
            cr.Fill();
            grad.Destroy();

            cr.Restore();
        }
コード例 #5
0
ファイル: PulsingButton.cs プロジェクト: knocte/hyena
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!pulsator.IsPulsing) {
                return base.OnDrawn (cr);
            }

            double x = Allocation.Width / 2;
            double y = Allocation.Height / 2;
            double r = Math.Min (Allocation.Width, Allocation.Height) / 2;
            double alpha = Choreographer.Compose (pulsator.Percent, Easing.Sine);

            Gdk.RGBA rgba = StyleContext.GetBackgroundColor (StateFlags.Selected);
            Cairo.Color color = CairoExtensions.GdkRGBAToCairoColor (rgba);
            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.Pattern = fill;
            cr.Fill ();
            fill.Destroy ();

            return base.OnDrawn (cr);
        }
コード例 #6
0
ファイル: PulsingButton.cs プロジェクト: rubenv/tripod
        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.Pattern = fill;
            cr.Fill ();
            fill.Destroy ();

            CairoExtensions.DisposeContext (cr);
            return base.OnExposeEvent (evnt);
        }