aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/Fill/Fill.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-02 23:38:54 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-02 23:38:54 +0100
commit67bd044b6e5fe52b8b76cc5d7eb8fd0ce9dc3ee9 (patch)
treeb94ae5e6ef363eab5f0888b459789ecea9ac5d5d /src/Fill/Fill.cs
parent2b087282dd73152d21140ea7312a90e046c84f61 (diff)
Gradient, Bitmap and Svg Filling
Diffstat (limited to 'src/Fill/Fill.cs')
-rw-r--r--src/Fill/Fill.cs32
1 files changed, 32 insertions, 0 deletions
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);
+ }
+
+ }
+}
+