本文整理汇总了C#中System.Random.NextColor方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NextColor方法的具体用法?C# Random.NextColor怎么用?C# Random.NextColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.NextColor方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Player
public Player(Project2Game game)
{
size = initSize;
moveSpeed = mSpeed;
spinSpeed = sSpeed;
Random rand = new Random();
color = rand.NextColor();
pos = game.landscape.getStartPoint();
pos.Y += size;
oldPos = Vector3.Zero;
rot = Matrix.Identity;
generateSphere(size, color);
vertices = Buffer.Vertex.New(
game.GraphicsDevice,
originalPoints);
this.effect = game.Content.Load<Effect>("Phong");
effect.Parameters["lightPntCol"].SetValue(game.sun.color.ToColor4());
inputLayout = VertexInputLayout.FromBuffer(0, vertices);
this.game = game;
}
示例2: Initialize
/// <summary>
/// /
/// </summary>
public override void Initialize ()
{
base.Initialize();
paramsCB = new ConstantBuffer( Game.GraphicsDevice, typeof(Params) );
CreateTargets();
LoadContent();
Random rand = new Random();
randomDir = new Texture2D( Game.GraphicsDevice, 64,64, ColorFormat.Rgba8, false );
randomDir.SetData( Enumerable.Range(0,4096).Select( i => rand.NextColor() ).ToArray() );
Game.GraphicsDevice.DisplayBoundsChanged += (s,e) => CreateTargets();
Game.Reloading += (s,e) => LoadContent();
}
示例3: OnRandomize
/// <summary>
/// Occurs during the randomizing process
/// </summary>
/// <param name="generator"></param>
protected override void OnRandomize(Random generator)
{
_color = generator.NextColor();
Opacity = generator.NextFloat();
_pointShape = generator.NextEnum<PointShape>();
base.OnRandomize(generator);
}
示例4: OnRandomize
///// <summary>
///// Adds SimpleStroke copy content
///// </summary>
///// <param name="copy"></param>
//protected override void OnCopy(Descriptor copy)
//{
// base.OnCopy(copy);
// ISimpleStroke ss = copy as ISimpleStroke;
// ss.Color = Color;
// ss.Width = Width;
// ss.DashStyle = this.DashStyle;
//}
/// <summary>
/// Handles randomization of simple stroke content
/// </summary>
/// <param name="generator">The random generator to use for randomizing characteristics.</param>
protected override void OnRandomize(Random generator)
{
_color = generator.NextColor();
Opacity = generator.NextFloat();
_width = generator.NextFloat(10);
_dashStyle = generator.NextEnum<DashStyle>();
base.OnRandomize(generator);
}
示例5: OnRandomize
/// <summary>
/// Extends the randomize code to include the character aspects, creating a random character.
/// However, since most fonts don't support full unicode values, a character from 0 to 255 is
/// chosen.
/// </summary>
/// <param name="generator">The random class generator</param>
protected override void OnRandomize(Random generator)
{
_color = generator.NextColor();
Opacity = generator.NextFloat();
_character = (char)generator.Next(0, 255);
_fontFamilyName = FontFamily.Families[generator.Next(0, FontFamily.Families.Length - 1)].Name;
_style = generator.NextEnum<FontStyle>();
base.OnRandomize(generator);
}
示例6: GenerateUniqueColors
/// <summary>
/// Calculates the unique colors as a scheme
/// </summary>
/// <param name="fs">The featureset with the data Table definition</param>
/// <param name="uniqueField">The unique field</param>
/// <param name="categoryFunc">Func for creating category</param>
protected Hashtable GenerateUniqueColors(IFeatureSet fs, string uniqueField, Func<Color, IFeatureCategory> categoryFunc)
{
if (categoryFunc == null) throw new ArgumentNullException("categoryFunc");
var result = new Hashtable(); // a hashtable of colors
var dt = fs.DataTable;
var vals = new ArrayList();
var i = 0;
var rnd = new Random();
foreach (DataRow row in dt.Rows)
{
var ind = -1;
if (uniqueField != "FID")
{
if (vals.Contains(row[uniqueField]) == false)
{
ind = vals.Add(row[uniqueField]);
}
}
else
{
ind = vals.Add(i);
i++;
}
if (ind == -1) continue;
var item = vals[ind];
var c = rnd.NextColor();
while (result.ContainsKey(c))
{
c = rnd.NextColor();
}
var cat = categoryFunc(c);
string flt = "[" + uniqueField + "] = ";
if (uniqueField == "FID")
{
flt += item;
}
else
{
if (dt.Columns[uniqueField].DataType == typeof(string))
{
flt += "'" + item + "'";
}
else
{
flt += Convert.ToString(item, CultureInfo.InvariantCulture);
}
}
cat.FilterExpression = flt;
AddCategory(cat);
result.Add(c, item);
}
return result;
}
示例7: GenerateUniqueColors
/// <summary>
/// Calculates the unique colors as a scheme
/// </summary>
/// <param name="fs">The featureset with the data Table definition</param>
/// <param name="uniqueField">The unique field</param>
public Hashtable GenerateUniqueColors(IFeatureSet fs, string uniqueField)
{
Hashtable result = new Hashtable(); // a hashtable of colors
DataTable dt = fs.DataTable;
ArrayList vals = new ArrayList();
int i = 0;
foreach (DataRow row in dt.Rows)
{
if (uniqueField != "FID")
{
if (vals.Contains(row[uniqueField]) == false)
{
vals.Add(row[uniqueField]);
}
}
else
{
vals.Add(i);
i++;
}
}
Random rnd = new Random();
foreach (object item in vals)
{
Color c = rnd.NextColor();
while (result.ContainsKey(c))
{
c = rnd.NextColor();
}
LineCategory cat = new LineCategory(c, 1);
string flt = "[" + uniqueField + "] = ";
if(uniqueField == "FID")
{
flt += item;
}
else
{
if (dt.Columns[uniqueField].DataType == typeof(string))
{
flt += "'" + item + "'";
}
else
{
flt += item.ToString();
}
}
cat.FilterExpression = flt;
Categories.Add(cat);
result.Add(c, item);
}
return result;
}
示例8: Draw
/// <summary>
/// Draw stuff here
/// </summary>
/// <param name="gameTime"></param>
/// <param name="stereoEye"></param>
protected override void Draw ( GameTime gameTime, StereoEye stereoEye )
{
var sb = GetService<SpriteBatch>();
var rand = new Random();
var data = Enumerable.Range(0,64*64)
.Select( i => rand.NextColor() )
.ToArray();
dynamicTexture.SetData(0, null, data, 0, 64*64 );
GraphicsDevice.SetTargets( dsMS.Surface, rtMS.Surface );
GraphicsDevice.Clear( dsMS.Surface );
GraphicsDevice.Clear( rtMS.Surface, Color4.Black );
sb.Begin(SpriteBlend.AlphaBlend,null,null, Matrix.OrthoRH(256,256,-1,1));
sb.DrawSprite( texture, 0,0,256, angle, Color.White );
sb.End();
GraphicsDevice.Resolve( rtMS, rt );
GraphicsDevice.RestoreBackbuffer();
int w = GraphicsDevice.DisplayBounds.Width;
int h = GraphicsDevice.DisplayBounds.Height;
// begin sprite gathering/accumulation :
sb.Begin();
if (InputDevice.IsKeyDown(Keys.T)) {
sb.Draw( texture2, 0, 0, 256, 256, Color.White );
sb.Draw( texture , 256+128*0, 0, 128, 128, Color.Red );
sb.Draw( texture2, 256+128*1, 0, 128, 128, Color.Lime );
sb.Draw( texture , 256+128*2, 0, 128, 128, Color.Blue );
} else {
sb.Draw( rt, 0, 0, 256, 256, Color.White );
sb.Draw( rt, 256+128*0, 0, 128, 128, Color.Red );
sb.Draw( rt, 256+128*1, 0, 128, 128, Color.Lime );
sb.Draw( rt, 256+128*2, 0, 128, 128, Color.Blue );
}
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.PointClamp);
sb.DrawSprite( texture, 576,192,128, angle, Color.White );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.LinearClamp);
sb.DrawSprite( texture, 704,192,128, angle, Color.White );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.PointClamp);
sb.DrawSprite( texture2, 576,192+128,128, angle, Color.White );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.LinearClamp);
sb.DrawSprite( texture2, 704,192+128,128, angle, Color.White );
sb.Restart();
for (int i=0; i<numSprites; i++) {
//sb.DrawSprite( sb.TextureWhite, r.Next(w), r.Next(h), 7, r.NextFloat(0,360), r.NextColor() );
sb.Draw( sb.TextureWhite, r.Next(w), r.Next(h), 7, 7, r.NextColor() );
}
var h1 = font1.LineHeight;
var h2 = font2.LineHeight;
font1.DrawString( sb, "Lenna Soderberg", 64, 256 + h1, Color.White );
font2.DrawString( sb, "Text (tracking = 0)", 64, 256 + h1+h2, Color.Red );
font2.DrawString( sb, "Text (tracking = 2)", 64, 256 + h1+h2*2, Color.Lime, 2 );
font2.DrawString( sb, "Text (tracking = 4)", 64, 256 + h1+h2*3, Color.Lime, 4 );
font2.DrawString( sb, string.Format("{1} sprites -> FPS = {0}", gameTime.Fps, numSprites), 64, 256 + h1+h2*4, Color.White );
sb.Restart( SpriteBlend.Additive );
sb.Draw( sb.TextureWhite, 256, 128, 128, 128, Color.Gray );
sb.Draw( texture, 256, 128, 128, 128, Color.Gray );
sb.Restart( SpriteBlend.AlphaBlend );
sb.Draw( sb.TextureWhite, 256+128, 128, 128, 128, new Color(240,225,160,255) );
sb.Restart( SpriteBlend.NegMultiply );
sb.Draw( texture, 256+128, 128, 128, 128, Color.White );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.AnisotropicWrap);
sb.DrawBeam( texture2, new Vector2(350,540), new Vector2(750,415), Color.Yellow, Color.LightYellow, 80, 5.5f, offset );
//.........这里部分代码省略.........
示例9: CreateUnboundedRandomColors
private static List<Color> CreateUnboundedRandomColors(int numColors)
{
Random rnd = new Random(DateTime.Now.Millisecond);
List<Color> result = new List<Color>(numColors);
for (int i = 0; i < numColors; i++)
{
result.Add(rnd.NextColor());
}
return result;
}