本文整理汇总了C#中IRenderable.GetTopLeft方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderable.GetTopLeft方法的具体用法?C# IRenderable.GetTopLeft怎么用?C# IRenderable.GetTopLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderable
的用法示例。
在下文中一共展示了IRenderable.GetTopLeft方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnqueueForRendering
public void EnqueueForRendering(IRenderable unit)
{
char[,] unitImage = unit.GetImage();
int imageRows = unitImage.GetLength(0);
int imageCols = unitImage.GetLength(1);
MatrixCoords unitTopLeft = unit.GetTopLeft();
int lastRow = Math.Min(unitTopLeft.Row + imageRows, Rows);
int lastCol = Math.Min(unitTopLeft.Col + imageCols, Cols);
for (int row = unit.GetTopLeft().Row; row < lastRow; row++)
{
for (int col = unit.GetTopLeft().Col; col < lastCol; col++)
{
if (row >= 0 && row < Rows && col >= 0 && col < Cols)
{
matrixToPrint[row, col] = unitImage[row - unit.GetTopLeft().Row, col - unit.GetTopLeft().Col];
}
}
}
}
示例2: EnqueueForRendering
public void EnqueueForRendering(IRenderable obj)
{
char[,] objImage = obj.GetImage();
int imageRows = objImage.GetLength(0);
int imageCols = objImage.GetLength(1);
MatrixCoords objTopLeft = obj.GetTopLeft();
int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderContextMatrixRows);
int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols);
for (int row = obj.GetTopLeft().Row; row < lastRow; row++)
{
for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
{
if (row >= 0 && row < renderContextMatrixRows &&
col >= 0 && col < renderContextMatrixCols)
{
renderContextMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col];
}
}
}
}
示例3: EnqueueForRendering
// this method adds an object for visualization.
public void EnqueueForRendering(IRenderable obj)
{
char[,] objImage = obj.GetImage();
int imageRows = objImage.GetLength(0);
int imageCols = objImage.GetLength(1);
MatrixCoords objTopLeft = obj.GetTopLeft(); // we extract the top left point from the object itself.
int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderContextMatrixRows); // prevents us from getting out of the console.
int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols); // prevents us from getting out of the console.
for (int row = obj.GetTopLeft().Row; row < lastRow; row++)
{
for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
{
if (row >= 0 && row < renderContextMatrixRows &&
col >= 0 && col < renderContextMatrixCols)
{
renderContextMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col];
}
}
}
}