本文整理汇总了C#中System.Color.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Color.GetLength方法的具体用法?C# Color.GetLength怎么用?C# Color.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Color
的用法示例。
在下文中一共展示了Color.GetLength方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaintFill
public static bool PaintFill(Color[,] colors, int r, int c, Color ncolor)
{
if (r < 0 || r >= colors.GetLength (0) || c < 0 || c >= colors.GetLength (1))
return false;
if (ncolor == colors [r, c])
return false;
return PaintFill (colors, r, c, colors [r, c], ncolor);
}
示例2: Print
private static void Print(Color[,] colors)
{
for (int r = 0; r < colors.GetLength (0); ++r) {
for (int c = 0; c < colors.GetLength (1); ++c) {
Console.Write (colors [r, c].ToString()[0] + " ");
}
Console.WriteLine ();
}
Console.WriteLine ();
}
示例3: Image
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image directly from an array of pixels
/// </summary>
/// <param name="pixels">2 dimensions array containing the pixels</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image(Color[,] pixels) :
base(IntPtr.Zero)
{
unsafe
{
fixed (Color* PixelsPtr = pixels)
{
uint Width = (uint)pixels.GetLength(0);
uint Height = (uint)pixels.GetLength(1);
SetThis(sfImage_CreateFromPixels(Width, Height, (byte*)PixelsPtr));
}
}
if (This == IntPtr.Zero)
throw new LoadingFailedException("image");
}
示例4: UpdatePixels
////////////////////////////////////////////////////////////
/// <summary>
/// Update the pixels of the image
/// </summary>
/// <param name="pixels">2 dimensions array containing the pixels</param>
/// <param name="x">X position of the rectangle to update</param>
/// <param name="y">Y position of the rectangle to update</param>
////////////////////////////////////////////////////////////
public void UpdatePixels(Color[,] pixels, uint x, uint y)
{
unsafe
{
fixed (Color* PixelsPtr = pixels)
{
int Width = pixels.GetLength(0);
int Height = pixels.GetLength(1);
sfImage_UpdatePixels(This, PixelsPtr, new IntRect((int)x, (int)y, Width, Height));
}
}
}
示例5: Image
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the image directly from an array of pixels
/// </summary>
/// <param name="pixels">2 dimensions array containing the pixels</param>
/// <exception cref="LoadingFailedException" />
////////////////////////////////////////////////////////////
public Image(Color[,] pixels) :
base(IntPtr.Zero)
{
uint Width = (uint)pixels.GetLength(0);
uint Height = (uint)pixels.GetLength(1);
// Transpose the array (.Net gives dimensions in reverse order of what SFML expects)
Color[,] transposed = new Color[Height, Width];
for (int x = 0; x < Width; ++x)
for (int y = 0; y < Height; ++y)
transposed[y, x] = pixels[x, y];
unsafe
{
fixed (Color* PixelsPtr = transposed)
{
SetThis(sfImage_createFromPixels(Width, Height, (byte*)PixelsPtr));
}
}
if (CPointer == IntPtr.Zero)
throw new LoadingFailedException("image");
}
示例6: recolor
public static Color[,] recolor(int[,] geo)
{
Color[,] geolocal = new Color[geo.GetLength(0), geo.GetLength(1)];
Random rn = new Random();
for (int t1 = 0; t1 < geolocal.GetLength(0) / 20; t1++)
{
for (int t2 = 0; t2 < geolocal.GetLength(1) / 20; t2++)
{
// int currTheme = (rn.Next(3) * 11) + (rn.Next(2) * 38);
// if (currTheme == 2 * 11 || currTheme == 11 + 38)
// break;
double hue = rn.Next(60) - 15;
hue = (Math.Abs(hue * 360) + hue) % 360;
for (int i = 0; i < 20; i++)
{
for (int j = 0; j < 20; j++)
{
if (geo[i + (t1 * 20), j + (t2 * 20)] == gr)
{
geolocal[i + (t1 * 20), j + (t2 * 20)] = Chroma.RandomBlend(Color.White, Color.FromHsv(hue, rn.NextDouble() / 2.5 + 0.2, 0.8), 0.05, 0.2);
}
else if (geo[i + (t1 * 20), j + (t2 * 20)] != da)// && geo[i + (t1 * 20), j + (t2 * 20)] != 1187)
{
geolocal[i + (t1 * 20), j + (t2 * 20)] = Chroma.RandomBlend(Color.White, Color.FromHsv(hue, rn.NextDouble() / 2.5 + 0.2, 0.8), 0.15, 0.3);
}
}
}
}
}
return geolocal;
}
示例7: Sprite
public Sprite(Color[,] layout)
{
_size = new Size(layout.GetLength(0), layout.GetLength(1));
_layout = layout;
}