本文整理汇总了C#中Color.RandomItem方法的典型用法代码示例。如果您正苦于以下问题:C# Color.RandomItem方法的具体用法?C# Color.RandomItem怎么用?C# Color.RandomItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.RandomItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildHexagon
private Body BuildHexagon(BodyRenderer renderer, Color[] colors, Hexagon hex, float radius, float spacing)
{
var pos = hex.GetPosition(spacing);
pos += new Vector2(radius) * Rand.Sign();
var color = colors.RandomItem();
return BuildHexagon(renderer, color, pos, radius, spacing);
}
示例2: GridDistribution
private Node GridDistribution(Rectangle area, Color[] colors, BodyRenderer renderer)
{
var hexagons = new Node();
var r = 8;
var x = r * (float)Math.Sqrt(3);
var y = r * 2f;
var n = area.Width / x - 1;
var m = area.Height / y - 1;
var o = new Vector2(r + 3, r);
var d = r;
for (var i = 0; i < n; i++)
{
o += new Vector2(0, d);
d = -d;
for (var j = 0; j < m; j++)
{
if (Rand.Float() < .6f)
continue;
var pos = o + new Vector2(i * x, j * y);
var color = colors.RandomItem();
hexagons.Add(BuildHexagon(renderer, color, pos, r, r));
}
}
return hexagons;
}
示例3: SpiralRingDistribution
private IEnumerable<Body> SpiralRingDistribution(BodyRenderer renderer, Color[] colors, Vector2 origin, float size, float spacing, int spiralRadius, float chance)
{
var hexagons = new List<Body>();
var center = new Hexagon(0, 0);
var color = colors.RandomItem();
var pos = origin + center.GetPosition(spacing);
//hexagons.Add(BuildHexagon(render, color, pos, size, spacing));
var ring = center.GetSpiralRing(spiralRadius);
foreach (var hexagon in ring)
{
pos = origin + hexagon.GetPosition(spacing);
var rand = Rand.Float();
if (rand < chance)
{
if (rand > chance / 2)
continue;
var newSize = size / 3;
var newSpacing = spacing / 3;
if (newSpacing > .5f)
{
hexagons.AddRange(SpiralRingDistribution(renderer, colors, pos, newSize, newSpacing, 1, chance));
}
continue;
}
color = colors.RandomItem();
hexagons.Add(BuildHexagon(renderer, color, pos, size, spacing));
}
return hexagons;
}