本文整理汇总了C#中BorderType.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# BorderType.HasFlag方法的具体用法?C# BorderType.HasFlag怎么用?C# BorderType.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BorderType
的用法示例。
在下文中一共展示了BorderType.HasFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generateHeights
private void generateHeights(float[,] border = null, BorderType borders = BorderType.None)
{
int step = size - 1;
int halfStep = step / 2;
while (halfStep != 0)
{
//diamond step
for (int y = 0; y < size - 1; y += step)
for (int x = 0; x < size - 1; x += step)
{
float a = this.heights[x, y];
float b = this.heights[x + step, y];
float c = this.heights[x, y + step];
float d = this.heights[x + step, y + step];
this.heights[x + halfStep, y + halfStep] = (a + b + c + d) / 4.0f + randd(this.d);
}
//square step
int o = 0;
for (int y = 0; y < size; y += halfStep, o++)
for (int x = (o % 2 == 0 ? halfStep : 0); x < size; x += step)
{
float a = (x - halfStep >= 0) ? heights[x - halfStep, y] : heights[x + halfStep, y];
float b = (y - halfStep >= 0) ? heights[x, y - halfStep] : heights[x, y + halfStep];
float c = (x + halfStep < this.size) ? heights[x + halfStep, y] : heights[x - halfStep, y];
float d = (y + halfStep < this.size) ? heights[x, y + halfStep] : heights[x, y - halfStep];
heights[x, y] = (a + b + d + c) / 4.0f + randd(this.d);
if (borders.HasFlag(BorderType.Left) && x == 0)
heights[x, y] = border[0, y];
if (borders.HasFlag(BorderType.Top) && y == 0)
heights[x, y] = border[1, x];
if (borders.HasFlag(BorderType.Right) && x == this.size - 1)
heights[x, y] = border[2, y];
if (borders.HasFlag(BorderType.Bottom) && y == this.size - 1)
heights[x, y] = border[3, x];
}
step /= 2;
halfStep = step/2;
this.d *= (float)Math.Pow(2, -r);
}
}