Inheritance: Pattern
Exemplo n.º 1
0
        public override void SetAsSource(Context ctx, Rectangle bounds = default(Rectangle))
        {
            Cairo.Gradient grad = null;
            switch (GradientType)
            {
            case Type.Vertical:
                grad = new Cairo.LinearGradient(bounds.Left, bounds.Top, bounds.Left, bounds.Bottom);
                break;

            case Type.Horizontal:
                grad = new Cairo.LinearGradient(bounds.Left, bounds.Top, bounds.Right, bounds.Top);
                break;

            case Type.Oblic:
                grad = new Cairo.LinearGradient(bounds.Left, bounds.Top, bounds.Right, bounds.Bottom);
                break;

            case Type.Radial:
                throw new NotImplementedException();
            }

            foreach (ColorStop cs in Stops)
            {
                grad.AddColorStop(cs.Offset, cs.Color);
            }

            ctx.SetSource(grad);
            grad.Dispose();
        }
 static void ShadowGradient(Cairo.Gradient lg, double strength)
 {
     lg.AddColorStop(0, new Cairo.Color(0, 0, 0, strength));
     lg.AddColorStop(1.0 / 6.0, new Cairo.Color(0, 0, 0, .85 * strength));
     lg.AddColorStop(2.0 / 6.0, new Cairo.Color(0, 0, 0, .54 * strength));
     lg.AddColorStop(3.0 / 6.0, new Cairo.Color(0, 0, 0, .24 * strength));
     lg.AddColorStop(4.0 / 6.0, new Cairo.Color(0, 0, 0, .07 * strength));
     lg.AddColorStop(5.0 / 6.0, new Cairo.Color(0, 0, 0, .01 * strength));
     lg.AddColorStop(1, new Cairo.Color(0, 0, 0, 0));
 }
Exemplo n.º 3
0
            static void GetShadowPattern(Cairo.Gradient shadow, ShadowParameters shadowParams)
            {
                double denLog = Math.Log(1.0f / shadowParams.shadowRadius);

                shadow.AddColorStop(0.0, new Cairo.Color(0, 0, 0, shadowParams.shadowAlpha));

                for (int i = 2; i <= shadowParams.shadowRadius; i++)
                {
                    double step = i / shadowParams.shadowRadius;
                    shadow.AddColorStop(step, new Cairo.Color(0, 0, 0, shadowParams.shadowAlpha * (Math.Log(step) / denLog)));
                }
            }
Exemplo n.º 4
0
 static void FillShadowPattern(Cairo.Context cairo, Cairo.Gradient shadow, ShadowParameters shadowParams)
 {
     GetShadowPattern(shadow, shadowParams);
     cairo.SetSource(shadow);
     cairo.Fill();
 }