Initial commit
This commit is contained in:
commit
0225d916ed
10 changed files with 4423 additions and 0 deletions
53
Shapes/Program.cs
Normal file
53
Shapes/Program.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System.Text;
|
||||
using Shapes;
|
||||
using Shapes.Shapes;
|
||||
using SimpleDrawing;
|
||||
using SimpleDrawing.Core;
|
||||
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
const int Size = 600;
|
||||
|
||||
var shapes = new List<Shape>();
|
||||
var generator = new ShapeGenerator(Size, Size);
|
||||
|
||||
LeoCanvas.Init(Run, Size, Size, clickAction: HandleClick, windowTitle: "Shapes");
|
||||
|
||||
return;
|
||||
|
||||
void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
// initial rendering
|
||||
Redraw();
|
||||
|
||||
Console.WriteLine("Press any key to exit...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleClick(ClickEvent @event)
|
||||
{
|
||||
// TODO - handle click at location
|
||||
|
||||
Redraw();
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
LeoCanvas.Clear();
|
||||
foreach (var shape in shapes)
|
||||
{
|
||||
if (!shape.DrawSelf())
|
||||
{
|
||||
Console.WriteLine($"Couldn't draw shape with id {shape.Id} 😭");
|
||||
}
|
||||
}
|
||||
LeoCanvas.Render();
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue