refactor: updated .Net version, removed unused vars, cleanup of code
This commit is contained in:
parent
e8670a252c
commit
cc66ee9d0e
@ -10,7 +10,7 @@ namespace FractalTreeGtk
|
||||
internal class CairoWindow : Window
|
||||
{
|
||||
private int FractalLevels { get; set; } = 2;
|
||||
readonly DrawingArea _drawing = new DrawingArea();
|
||||
readonly DrawingArea _drawing = new();
|
||||
Fractal _fractal = null!;
|
||||
|
||||
public CairoWindow(string title) : base(title)
|
||||
@ -44,9 +44,9 @@ namespace FractalTreeGtk
|
||||
FractalLevels--;
|
||||
GenerateFractal();
|
||||
}
|
||||
|
||||
break;
|
||||
case Key.r: //Regenerate fractal
|
||||
case Key.R:
|
||||
GenerateFractal();
|
||||
break;
|
||||
}
|
||||
|
@ -6,11 +6,10 @@ namespace FractalTreeGtk.Draw
|
||||
{
|
||||
private readonly CairoWindow _window;
|
||||
private double Length { get; set; } = new Random().Next(70, 90);
|
||||
private int MaxLevels { get; set; }
|
||||
private int CurrentLevel { get; set; } = 0;
|
||||
public bool IsDrawing { private set; get; }
|
||||
private int MaxLevels { get; }
|
||||
private int CurrentLevel { get; set; }
|
||||
private double Degree => new Random().Next(30, 50) / 100f;
|
||||
private double DeltaLength => new Random().Next(0, 50) / 100f;
|
||||
private double DeltaLength => new Random().Next(0, 20) / (float)Math.Log2(CurrentLevel+1);
|
||||
|
||||
public Branch[][] FractalLines { get; }
|
||||
|
||||
@ -38,7 +37,7 @@ namespace FractalTreeGtk.Draw
|
||||
{
|
||||
_window.QueueDraw();
|
||||
var len = DeltaLength;
|
||||
if (Length < DeltaLength)
|
||||
if (Length < 0)
|
||||
Length = DeltaLength;
|
||||
else
|
||||
Length -= DeltaLength;
|
||||
@ -94,7 +93,6 @@ namespace FractalTreeGtk.Draw
|
||||
{
|
||||
NextLevel();
|
||||
}
|
||||
else IsDrawing = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
@ -1,18 +1,14 @@
|
||||
using Gtk;
|
||||
|
||||
namespace FractalTreeGtk
|
||||
namespace FractalTreeGtk;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
internal class Program
|
||||
static void Main()
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Application.Init();
|
||||
Application.Init();
|
||||
|
||||
//Create the Window
|
||||
|
||||
Window myWin = new CairoWindow("My first GTK# Application! ");
|
||||
|
||||
Application.Run();
|
||||
}
|
||||
_ = new CairoWindow("Fractal window");
|
||||
Application.Run();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user