//Assumption: // ArrayFromGridPoint(p1 + offset) == ArrayFromGridPoint(p1) + ArrayFromGridPoint(offset) public TShapeInfo Translate(TVectorPoint offset) { Func <TPoint, bool> newIsInside = x => shapeStorageStorageInfo.contains(x.Subtract(offset)); var newStorageRect = shapeStorageStorageInfo.storageRect .Translate(ArrayPointFromGridPoint(offset)); return(MakeShapeInfo(new ShapeStorageInfo <TPoint>(newStorageRect, newIsInside))); }
public ShapeStorageInfo <TPoint> Difference(ShapeStorageInfo <TPoint> other) { Func <TPoint, bool> newIsInside = x => contains(x) && !other.contains(x); var newStorageRect = storageRect.Difference(other.storageRect); return(new ShapeStorageInfo <TPoint>(newStorageRect, newIsInside)); }
public ShapeStorageInfo <TPoint> Union(ShapeStorageInfo <TPoint> other) { Func <TPoint, bool> newIsInside = x => contains(x) || other.contains(x); var newStorageRect = storageRect.Union(other.storageRect); return(new ShapeStorageInfo <TPoint>(newStorageRect, newIsInside)); }
/** * This creates a shape described by a shape of the base point shape op. * Typicaly usage: * \code * [ShapeMethod] * public FlatRhombShapeInfo<TCell> SomeShape(...) * { * return ShapeFromBase(FlatHexGrid<TCell>.BeginShape().SomeShape(...)); * } * \endcode */ public FlatRhombShapeInfo <TCell> ShapeFromBase(FlatHexShapeInfo <TCell> baseShapeInfo) { ShapeStorageInfo <FlatHexPoint> storageInfo = baseShapeInfo.ShapeStorageStorageInfo; var storageRect = storageInfo.storageRect; Func <FlatRhombPoint, bool> isInside = x => storageInfo.contains(x.BasePoint); var shapeInfo = MakeShapeStorageInfo <FlatRhombPoint>(storageRect, isInside); return(new FlatRhombShapeInfo <TCell>(shapeInfo)); }
/** * This creates a shape described by a shape of the base point shape op. * Typicaly usage: * \code * [ShapeMethod] * public CairoShapeInfo<TCell> SomeShape(...) * { * return ShapeFromBase(PointyHexGrid<TCell>.BeginShape().SomeShape(...)); * } * \endcode */ public CairoShapeInfo <TCell> ShapeFromBase(PointyHexShapeInfo <TCell> baseShapeInfo) { ShapeStorageInfo <PointyHexPoint> storageInfo = baseShapeInfo.ShapeStorageStorageInfo; var storageRect = storageInfo.storageRect; Func <CairoPoint, bool> isInside = x => storageInfo.contains(x.BasePoint); var shapeInfo = MakeShapeStorageInfo <CairoPoint>(storageRect, isInside); return(new CairoShapeInfo <TCell>(shapeInfo)); }