Exemple #1
0
        protected override RequestedAction RenderEffects(ImageState s)
        {
            if (base.RenderEffects(s) == RequestedAction.Cancel)
            {
                return(RequestedAction.Cancel);                                                 //Call extensions
            }
            if (s.destGraphics == null)
            {
                return(RequestedAction.None);
            }

            //parse shadow
            Color shadowColor = ParseUtils.ParseColor(s.settings["shadowColor"], Color.Transparent);
            int   shadowWidth = s.settings.Get <int>("shadowWidth", -1);

            //Skip on transparent or 0-width shadow
            if (shadowColor == Color.Transparent || shadowWidth <= 0)
            {
                return(RequestedAction.None);
            }

            using (Brush b = new SolidBrush(shadowColor)) {
                //Offsets may show inside the shadow - so we have to fix that
                s.destGraphics.FillPolygon(b,
                                           PolygonMath.InflatePoly(s.layout["shadowInner"], 1)); //Inflate 1 for FillPolygon rounding errors.
            }
            //Then we can draw the outer gradient
            DrawOuterGradient(s.destGraphics, s.layout["shadowInner"],
                              shadowColor, Color.Transparent, shadowWidth);

            return(RequestedAction.None);
        }
Exemple #2
0
        protected override RequestedAction LayoutEffects(ImageState s)
        {
            float shadowWidth = s.settings.Get <float>("shadowWidth", 0);

            if (shadowWidth != 0)
            {
                var    offset       = s.settings.GetList <float>("shadowOffset", 0, 2);
                PointF shadowOffset = offset == null ? new PointF(0, 0) : new PointF(offset[0], offset[1]);

                //Clone last ring, then offset it - provides the inner bounds of the shadow later
                s.layout.AddInvisiblePolygon("shadowInner", PolygonMath.MovePoly(s.layout.LastRing.points, shadowOffset));

                //Determine the outer bound of the shadow
                s.layout.AddRing("shadow", PolygonMath.InflatePoly(s.layout.LastRing.points, new float[] {
                    Math.Max(0, shadowWidth - shadowOffset.Y),
                    Math.Max(0, shadowWidth + shadowOffset.X),
                    Math.Max(0, shadowWidth + shadowOffset.Y),
                    Math.Max(0, shadowWidth - shadowOffset.X)
                }));
            }
            return(RequestedAction.None);
        }
Exemple #3
0
 /// <summary>
 /// Inflates the last ring using the specified padding options. Returns the resulting ring object
 /// </summary>
 /// <param name="name"></param>
 /// <param name="padding"></param>
 /// <returns></returns>
 public PointSet AddRing(string name, BoxPadding padding)
 {
     return(AddRing(name, PolygonMath.InflatePoly(LastRing.points, padding.GetEdgeOffsets())));
 }