Test simple render conveyer.

This commit is contained in:
THE_KONDRAT 2025-04-16 10:48:42 +03:00
parent cabf659514
commit a7fbf6ad7d
9 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,14 @@
using Domain.Abstractions;
namespace Domain;
public class FramePartRenderResult
{
public uint Row { get; set; }
public uint Column { get; set; }
public uint FrameSizeX { get; set; }
public uint FrameSizeY { get; set; }
// или пиксели?
public string Frame { get; set; }
}

View File

View File

@ -0,0 +1,77 @@
using System;
namespace Domain;
public class ConsoleImageDrawer
{
private char[,]? _image; // Изображение хранится внутри класса
// 1. Нарисовать изображение
public void DrawImage(char[,] image)
{
Console.Clear();
_image = image;
for (int i = 0; i < _image.GetLength(0); i++)
{
for (int j = 0; j < _image.GetLength(1); j++)
{
Console.SetCursorPosition(j, i);
Console.Write(_image[i, j]);
}
}
}
// 2. Заменить фон в указанной области на цвет
public void SetBackgroundColor(int startRow, int startCol, int height, int width, ConsoleColor color)
{
if (_image == null)
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Image is not set");
Console.ForegroundColor = ConsoleColor.Black;
return;
}
Console.BackgroundColor = color;
for (int i = startRow; i < Math.Min(startRow + height, _image.GetLength(0)); i++)
{
for (int j = startCol; j < Math.Min(startCol + width, _image.GetLength(1)); j++)
{
Console.SetCursorPosition(j, i);
Console.Write(_image[i, j]);
}
}
Console.ResetColor(); // Сброс цвета
}
// 3. Отменить фон (вернуть черный)
public void ResetBackgroundColor(int startRow, int startCol, int height, int width)
{
SetBackgroundColor(startRow, startCol, height, width, ConsoleColor.Black);
}
// 4. Изменить цвет указанного символа
public void SetCharacterColor(int row, int col, ConsoleColor foregroundColor)
{
if (_image == null)
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Image is not set");
Console.ForegroundColor = ConsoleColor.Black;
return;
}
if (row >= 0 && row < _image.GetLength(0) && col >= 0 && col < _image.GetLength(1))
{
Console.SetCursorPosition(col, row);
Console.ForegroundColor = foregroundColor;
Console.Write(_image[row, col]);
Console.ResetColor(); // Сброс цвета
}
}
// 5. Стереть изображение
public void ClearImage()
{
Console.Clear();
}
}

View File

6
Domain/RenderResult.cs Normal file
View File

@ -0,0 +1,6 @@
namespace Domain.Abstractions;
public class RenderResult
{
public List<>
}

26
Make3.Renderer/test1.txt Normal file
View File

@ -0,0 +1,26 @@
.:^. ::.
.:~77??: !??7!^:
:!7??????: !??????7~.
:7?????????: !?????????~.
.!???????????: !???????????^
.7????????????: !????????????~
.7?????????????: !?????????????~
!??????????????: !??????????????:
.???????????????: !??????????????!
^???????????????: !??????????????7
:???????????????~ .7??????????????7
.????????????????~. .:7???????????????!
~?????????????????77!7??????????????????.
7?????????????????????????????????????^
.7J??????????????????????????????????^
~?J?????????????????????????????J7:
.!?JJ???????????????????????JJ7^
.~7?JJJ???????????????JJJ?!:
.^!7???JJJJJJJJ????7~:.
..:^^~~~~~^^:.

View File

0
Make3.Renderer/test2.txt Normal file
View File