/// <summary>
        /// Merges partial styles.
        /// </summary>
        public static void Merge(PartialFontStyle style1, PartialFontStyle style2, float weight,
                                 out IFill fill, out Pen pen)
        {
            if (style1 == null && style2 == null)
            {
                fill = null;
                pen  = null;
                return;
            }

            if (style2 != null && style1 == null)
            {
                Merge(style2, style1, 1.0f - weight, out fill, out pen);
                return;
            }

            if (style2 == null)
            {
                fill = style1.Fill;
                pen  = style1.Pen;
                return;
            }

            fill = BlendedFill.BlendFills(style1.Fill, style2.Fill, weight);
            pen  = Pen.BlendPens(style1.Pen, style2.Pen, weight);

            return;
        }
Example #2
0
        /// <summary>
        /// Blends styles.
        /// </summary>
        public static Pen Merge(BorderStyle style1, BorderStyle style2, float weight,
                                out ITransform transform, out IMapper mapper)
        {
            if (style1 == null && style2 == null)
            {
                transform = null;
                mapper    = null;
                return(null);
            }
            if (style2 != null && style1 == null)
            {
                return(Merge(style2, style1, 1.0f - weight, out transform, out mapper));
            }

            if (style2 == null)
            {
                transform = style1.MappingTransform;
                mapper    = style1.Mapper;
                return(style1.Pen);
            }

            transform = BlendTransform.BlendTransforms(style1.MappingTransform,
                                                       style2.MappingTransform, weight);
            mapper = style1.Mapper;

            return(Pen.BlendPens(style1.Pen, style2.Pen, weight));
        }
Example #3
0
        /// <summary>
        /// Merges font styles.
        /// </summary>
        /// <returns></returns>
        public static Font Merge(FontStyle style1, FontStyle style2, float weight,
                                 out float size, out float lineSpacing, out TextOptions options,
                                 out Pen pen, out IFill fill)
        {
            // No font.
            if (style1 == null && style2 == null)
            {
                size        = 0;
                lineSpacing = 0;
                options     = TextOptions.None;
                pen         = null;
                fill        = null;
                return(null);
            }

            // Special case second style only.
            if (style1 == null && style2 != null)
            {
                return(Merge(style2, style1, 1.0f - weight, out size,
                             out lineSpacing, out options, out pen, out fill));
            }

            if (style1 != null && style2 == null)
            {
                size        = style1.Size;
                lineSpacing = style1.LineSpacing;
                options     = style1.TextOptions;
                pen         = style1.Pen;
                fill        = style1.Fill;

                return(style1.Font);
            }

            float w1 = 1.0f - weight;

            size        = style1.Size * w1 + style2.Size * weight;
            lineSpacing = style1.LineSpacing * w1 + style2.LineSpacing * weight;
            options     = style1.TextOptions;
            pen         = Pen.BlendPens(style1.Pen, style2.Pen, weight);
            fill        = BlendedFill.BlendFills(style1.Fill, style2.Fill, weight);

            return(style1.Font);
        }