Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1727e1f1ad | ||
![]() |
cc66ee9d0e | ||
![]() |
e8670a252c |
@ -10,7 +10,7 @@ namespace FractalTreeGtk
|
|||||||
internal class CairoWindow : Window
|
internal class CairoWindow : Window
|
||||||
{
|
{
|
||||||
private int FractalLevels { get; set; } = 2;
|
private int FractalLevels { get; set; } = 2;
|
||||||
readonly DrawingArea _drawing = new DrawingArea();
|
readonly DrawingArea _drawing = new();
|
||||||
Fractal _fractal = null!;
|
Fractal _fractal = null!;
|
||||||
|
|
||||||
public CairoWindow(string title) : base(title)
|
public CairoWindow(string title) : base(title)
|
||||||
@ -44,9 +44,9 @@ namespace FractalTreeGtk
|
|||||||
FractalLevels--;
|
FractalLevels--;
|
||||||
GenerateFractal();
|
GenerateFractal();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Key.r: //Regenerate fractal
|
case Key.r: //Regenerate fractal
|
||||||
|
case Key.R:
|
||||||
GenerateFractal();
|
GenerateFractal();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,10 @@ namespace FractalTreeGtk.Draw
|
|||||||
{
|
{
|
||||||
private readonly CairoWindow _window;
|
private readonly CairoWindow _window;
|
||||||
private double Length { get; set; } = new Random().Next(70, 90);
|
private double Length { get; set; } = new Random().Next(70, 90);
|
||||||
private int MaxLevels { get; set; }
|
private int MaxLevels { get; }
|
||||||
private int CurrentLevel { get; set; } = 0;
|
private int CurrentLevel { get; set; }
|
||||||
public bool IsDrawing { private set; get; }
|
|
||||||
private double Degree => new Random().Next(30, 50) / 100f;
|
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; }
|
public Branch[][] FractalLines { get; }
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ namespace FractalTreeGtk.Draw
|
|||||||
{
|
{
|
||||||
_window.QueueDraw();
|
_window.QueueDraw();
|
||||||
var len = DeltaLength;
|
var len = DeltaLength;
|
||||||
if (Length < DeltaLength)
|
if (Length < 0)
|
||||||
Length = DeltaLength;
|
Length = DeltaLength;
|
||||||
else
|
else
|
||||||
Length -= DeltaLength;
|
Length -= DeltaLength;
|
||||||
@ -94,7 +93,6 @@ namespace FractalTreeGtk.Draw
|
|||||||
{
|
{
|
||||||
NextLevel();
|
NextLevel();
|
||||||
}
|
}
|
||||||
else IsDrawing = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
using Gtk;
|
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
|
_ = new CairoWindow("Fractal window");
|
||||||
|
Application.Run();
|
||||||
Window myWin = new CairoWindow("My first GTK# Application! ");
|
|
||||||
|
|
||||||
Application.Run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user