From 67bd044b6e5fe52b8b76cc5d7eb8fd0ce9dc3ee9 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Tue, 2 Feb 2016 23:38:54 +0100 Subject: Gradient, Bitmap and Svg Filling --- src/Fill/Fill.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Fill/Fill.cs (limited to 'src/Fill') diff --git a/src/Fill/Fill.cs b/src/Fill/Fill.cs new file mode 100644 index 00000000..322fa5ae --- /dev/null +++ b/src/Fill/Fill.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; + +namespace Crow +{ + public abstract class Fill + { + public abstract void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle)); + public static object Parse (string s){ + if (string.IsNullOrEmpty (s)) + return null; + if (s.Substring (1).StartsWith ("gradient")) + return (Gradient)Gradient.Parse (s); + if (s.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture)) + return SvgPicture.Parse (s); + if (s.EndsWith (".png", true, System.Globalization.CultureInfo.InvariantCulture) || + s.EndsWith (".jpg", true, System.Globalization.CultureInfo.InvariantCulture) || + s.EndsWith (".jpeg", true, System.Globalization.CultureInfo.InvariantCulture) || + s.EndsWith (".bmp", true, System.Globalization.CultureInfo.InvariantCulture) || + s.EndsWith (".gif", true, System.Globalization.CultureInfo.InvariantCulture)) + return BmpPicture.Parse (s); + + return (SolidColor)SolidColor.Parse (s); + } + + public static implicit operator Fill(Color c){ + return new SolidColor (c); + } + + } +} + -- cgit v1.3.1-4-g156e