From 610dd6bb08138388ecdab8f86bbe556569490893 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Tue, 2 Feb 2016 12:10:35 +0100 Subject: [PATCH] IFill implementation --- Crow.csproj | 1 + src/Cairo/IFill.cs | 11 +++++++++++ src/Colors.cs | 11 ++++++++++- src/GraphicObjects/GraphicObject.cs | 2 +- src/OpenTKGameWindow.cs | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/Cairo/IFill.cs diff --git a/Crow.csproj b/Crow.csproj index 7a253dae..26f028c1 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -130,6 +130,7 @@ + diff --git a/src/Cairo/IFill.cs b/src/Cairo/IFill.cs new file mode 100644 index 00000000..e3459bb0 --- /dev/null +++ b/src/Cairo/IFill.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace Crow +{ + public interface ICairoFill + { + void SetAsSource (Cairo.Context ctx); + } +} + diff --git a/src/Colors.cs b/src/Colors.cs index 61f9208f..b83a2a96 100644 --- a/src/Colors.cs +++ b/src/Colors.cs @@ -10,7 +10,7 @@ using System.Diagnostics; namespace Crow { - public struct Color + public struct Color : ICairoFill { #region CTOR public Color(double _R, double _G, double _B, double _A) @@ -148,6 +148,15 @@ namespace Crow return new Color (this.R, this.G, this.B, _A); } + #region IFill implementation + + public void SetAsSource (Cairo.Context ctx) + { + ctx.SetSourceRGBA (R, G, B, A); + } + + #endregion + #region Predefined colors public static readonly Color Transparent = new Color(0, 0, 0, 0, "Transparent"); public static readonly Color Clear = new Color(-1, -1, -1, -1, "Clear"); diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 99513f14..cef2c501 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -707,7 +707,7 @@ namespace Crow { Rectangle rBack = new Rectangle (Slot.Size); - gr.SetSourceColor(Background); + Background.SetAsSource (gr); CairoHelpers.CairoRectangle(gr,rBack,_cornerRadius); gr.Fill (); } diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index ba458b54..a62f79f1 100644 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -294,7 +294,7 @@ namespace Crow #if DEBUG_CLIP_RECTANGLE redrawClip.stroke (ctx, new Color(1.0,0,0,0.3)); #endif - redrawClip.clearAndClip (ctx);//rajouté après, tester si utile + redrawClip.clearAndClip (ctx); //Link.draw (ctx); foreach (GraphicObject p in invGOList) { -- 2.47.3