Example #1
0
        public override void Apply(CanvasItem item, Context cr)
        {
            int    steps        = ShadowSize;
            double opacity_step = ShadowOpacity / ShadowSize;
            var    color        = new Color(0, 0, 0);

            double width  = Math.Round(item.Allocation.Width);
            double height = Math.Round(item.Allocation.Height);

            if (Fill != null)
            {
                cr.Rectangle(ShadowSize, ShadowSize, width - ShadowSize * 2, height - ShadowSize * 2);
                Fill.Apply(cr);
                cr.Fill();
            }

            cr.LineWidth = 1.0;

            for (int i = 0; i < steps; i++)
            {
                CairoExtensions.RoundedRectangle(cr,
                                                 i + 0.5,
                                                 i + 0.5,
                                                 (width - 2 * i) - 1,
                                                 (height - 2 * i) - 1,
                                                 steps - i);

                color.A = opacity_step * (i + 1);
                cr.SetSourceColor(color);
                cr.Stroke();
            }
        }