本文整理汇总了C#中Shape.CreateTexture方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.CreateTexture方法的具体用法?C# Shape.CreateTexture怎么用?C# Shape.CreateTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape.CreateTexture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static Shape Load(string fn)
{
if (!System.IO.File.Exists(fn))
throw new System.Exception("File not found: " + fn);
System.IO.BinaryReader br = new System.IO.BinaryReader(new System.IO.FileStream(fn, System.IO.FileMode.Open));
Shape s = new Shape();
s.Width = br.ReadInt32();
s.Height = br.ReadInt32();
s.matrix = new bool[s.Width, s.Height];
try
{
for (int x = 0; x < s.Width; x++)
for (int y = 0; y < s.Height; y++)
s.notEmptyCellsCount += (s.matrix[x, y] = br.ReadBoolean()) ? 1 : 0;
}
catch (System.IO.EndOfStreamException)
{
throw new System.Exception("Invalid data for shape " + fn);
}
br.Close();
s.CreateTexture();
return s;
}
示例2: Create
public static Shape Create(bool[,] matrix)
{
Shape s = new Shape();
s.Width = matrix.GetLength(0);
s.Height = matrix.GetLength(1);
s.matrix = new bool[s.Width, s.Height];
for (int x = 0; x < s.Width; x++)
for (int y = 0; y < s.Height; y++)
s.matrix[x, y] = matrix[x, y];
s.CreateTexture();
return s;
}