/// <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; }
/// <summary> /// Merges background styles. /// </summary> public static IFill Merge(BackgroundStyle style1, BackgroundStyle style2, float weight, out ITransform blendTransform, out IMapper mapper) { if (style1 == null && style2 == null) { blendTransform = null; mapper = null; return(null); } if (style1 == null && style2 != null) { return(Merge(style2, style1, 1.0f - weight, out blendTransform, out mapper)); } if (style2 == null) { mapper = style1.Mapper; blendTransform = style1.MappingTransform; return(style1.Fill); } blendTransform = BlendTransform.BlendTransforms(style1.MappingTransform, style2.MappingTransform, weight); mapper = style2.Mapper; return(BlendedFill.BlendFills(style1.Fill, style2.Fill, weight)); }
/// <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); }