public override IExplicitShape <int> Transform(IExplicitShape <int> input) { var shape = input.Translate(offset); var storageRect = GridInterval.Translate(input.Bounds, offset); return(shape.ToExplicit(storageRect)); }
public override IExplicitShape <GridPoint3> Transform(IExplicitShape <GridPoint3> input) { var offset1 = offset.GetGridPoint(); var shape = input.Translate(offset1); var storageRect = GridBounds.Translate(input.Bounds, offset1); return(shape.ToExplicit(storageRect)); }
public static IExplicitShape <GridPoint3> CenterOnOrigin(this IExplicitShape <GridPoint3> shape) { var size = shape.Bounds.Size / 2; var newPoint = -size; var translation = newPoint - shape.Bounds.Point; return(shape.Translate(translation)); }
public IExplicitShape <GridPoint2> Place(IExplicitShape <GridPoint2> shape, GridPoint2 point, T item) { if (!Contains(shape, point)) { throw new InvalidOperationException("Shape is not completely in grid."); } if (!IsEmpty(shape, point)) { throw new InvalidOperationException("Shape is not completely empty."); } var offsetShape = shape.Translate(point); foreach (var shapePoint in offsetShape.Points) { grid[shapePoint] = item; shapes[shapePoint] = offsetShape; } return(offsetShape); }
public bool IsEmpty(IExplicitShape <GridPoint2> shape, GridPoint2 point) { var offsetShape = shape.Translate(point); return(offsetShape.Points.All(p => shapes[p] == null)); }
public bool Contains(IExplicitShape <GridPoint2> shape, GridPoint2 point) { var offsetShape = shape.Translate(point); return(offsetShape.Points.All(p => grid.Contains(p))); }
public TightShape2 ToCanonicalPosition() { var newShape = shape.Translate(-shape.Bounds.Point); return(new TightShape2(newShape, true)); }