本文整理汇总了C#中Shape.CalcBoundingBox2D方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.CalcBoundingBox2D方法的具体用法?C# Shape.CalcBoundingBox2D怎么用?C# Shape.CalcBoundingBox2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape.CalcBoundingBox2D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DistanceGrid
public DistanceGrid(Shape shape, Scalar spacing)
{
if (shape == null) { throw new ArgumentNullException("shape"); }
if (spacing <= 0) { throw new ArgumentOutOfRangeException("spacing"); }
//prepare the shape.
Matrix2D old = shape.Matrix;
Matrix2D ident = Matrix2D.Identity;
shape.ApplyMatrix(ref ident);
shape.CalcBoundingBox2D();
this.box = shape.BoundingBox2D;
this.gridSpacing = spacing;
this.gridSpacingInv = 1 / spacing;
int xSize = (int)Math.Ceiling((box.Upper.X - box.Lower.X) * gridSpacingInv) + 2;
int ySize = (int)Math.Ceiling((box.Upper.Y - box.Lower.Y) * gridSpacingInv) + 2;
this.nodes = new Scalar[xSize, ySize];
Vector2D vector;
vector.X = box.Lower.X;
for (int x = 0; x < xSize; ++x, vector.X += spacing)
{
vector.Y = box.Lower.Y;
for (int y = 0; y < ySize; ++y, vector.Y += spacing)
{
nodes[x, y] = shape.GetDistance(vector);
}
}
//restore the shape
shape.ApplyMatrix(ref old);
shape.CalcBoundingBox2D();
}