From 5f68cf21b47b88e4e1de7fed7bd9b8b56b5dfa3d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Sun, 13 Aug 2017 19:11:00 +0200 Subject: cairo.region to handle clipping, native pointer leaking... --- src/Rectangles.cs | 137 ------------------------------------------------------ 1 file changed, 137 deletions(-) delete mode 100644 src/Rectangles.cs (limited to 'src/Rectangles.cs') diff --git a/src/Rectangles.cs b/src/Rectangles.cs deleted file mode 100644 index 7310290d..00000000 --- a/src/Rectangles.cs +++ /dev/null @@ -1,137 +0,0 @@ -// -// Rectangles.cs -// -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Cairo; -using System.Diagnostics; - -namespace Crow -{ - public class Rectangles - { - public List list = new List(); - public int count - { - get { return list.Count; } - } - - public void AddRectangle(Rectangle r) - { - if (doesNotContain (r)) { - list.Add (r); - boundsUpToDate = false; - } - } - public void Reset() - { - list = new List(); - _bounds = Rectangle.Empty; - boundsUpToDate = true; - } - bool doesNotContain(Rectangle r) - { - foreach (Rectangle rInList in list) - if (rInList.ContainsOrIsEqual(r)) - return false; - return true; - } - - public bool intersect(Rectangle r) - { - foreach (Rectangle rInList in list) - if (rInList.Intersect(r)) - return true; - return false; - } - public void stroke(Context ctx, Color c) - { - foreach (Rectangle r in list) - ctx.Rectangle(r); - - ctx.SetSourceColor(c); - - ctx.LineWidth = 2; - ctx.Stroke (); - } - public void clearAndClip(Context ctx) - { - if (list.Count == 0) - return; - foreach (Rectangle r in list) - ctx.Rectangle(r); - - ctx.ClipPreserve(); - ctx.Operator = Operator.Clear; - ctx.Fill(); - ctx.Operator = Operator.Over; - } - - public void clip(Context ctx) - { - foreach (Rectangle r in list) - ctx.Rectangle(r); - - ctx.Clip(); - } - - Rectangle _bounds; - bool boundsUpToDate = true; - public Rectangle Bounds { - get { - if (!boundsUpToDate) { - if (list.Count > 0) { - _bounds = list [0]; - for (int i = 1; i < list.Count; i++) { - _bounds += list [i]; - } - } else - _bounds = Rectangle.Empty; - boundsUpToDate = true; - } - return _bounds; - } - } - public void clear(Context ctx) - { - foreach (Rectangle r in list) - ctx.Rectangle(r); - ctx.Operator = Operator.Clear; - ctx.Fill(); - ctx.Operator = Operator.Over; - } - public override string ToString () - { - string tmp = ""; - foreach (Rectangle r in list) { - tmp += r.ToString (); - } - return tmp; - } - } -} -- cgit v1.3.1-4-g156e