Exemplo n.º 1
0
        private StylePen interpolatePen(StylePen min, StylePen max, Double attr)
        {
            Double frac = fraction(attr);

            StyleColor color = StyleColor.Interpolate(min.BackgroundBrush.Color, max.BackgroundBrush.Color, frac);
            StylePen   pen   = new StylePen(color, interpolateDouble(min.Width, max.Width, attr));

            pen.MiterLimit = interpolateFloat(min.MiterLimit, max.MiterLimit, attr);
            pen.StartCap   = (frac > 0.5 ? max.StartCap : min.StartCap);
            pen.EndCap     = (frac > 0.5 ? max.EndCap : min.EndCap);
            pen.LineJoin   = (frac > 0.5 ? max.LineJoin : min.LineJoin);
            pen.DashStyle  = (frac > 0.5 ? max.DashStyle : min.DashStyle);

            if (min.DashStyle == LineDashStyle.Custom && max.DashStyle == LineDashStyle.Custom)
            {
                pen.DashPattern = (frac > 0.5 ? max.DashPattern : min.DashPattern);
            }

            pen.DashOffset = (frac > 0.5 ? max.DashOffset : min.DashOffset);
            pen.DashCap    = (frac > 0.5 ? max.DashCap : min.DashCap);

            if (min.CompoundArray.Length > 0 && max.CompoundArray.Length > 0)
            {
                pen.CompoundArray = (frac > 0.5 ? max.CompoundArray : min.CompoundArray);
            }

            pen.Alignment = (frac > 0.5 ? max.Alignment : min.Alignment);
            //pen.CustomStartCap = (frac > 0.5 ? max.CustomStartCap : min.CustomStartCap);  //Throws ArgumentException
            //pen.CustomEndCap = (frac > 0.5 ? max.CustomEndCap : min.CustomEndCap);  //Throws ArgumentException
            return(pen);
        }
Exemplo n.º 2
0
 private StyleBrush interpolateBrush(StyleBrush min, StyleBrush max, Double attr)
 {
     return(new SolidStyleBrush(StyleColor.Interpolate(min.Color, max.Color, fraction(attr))));
 }