Compare commits

...

3 Commits
v1.0.0 ... main

Author SHA1 Message Date
Savely Savianok
1727e1f1ad
Update README.md 2025-02-02 22:11:29 +03:00
nikita_ve
cc66ee9d0e refactor: updated .Net version, removed unused vars, cleanup of code 2025-01-19 19:35:29 +03:00
Savely Savianok
e8670a252c
Update README.md 2024-11-23 16:12:40 +03:00
5 changed files with 15 additions and 21 deletions

View File

@ -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;
} }

View File

@ -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;
} }
} }
} }

View File

@ -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>

View File

@ -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();
}
} }
} }

View File

@ -1,5 +1,5 @@
# Fractal renderer on Gtk# # Fractal renderer on Gtk#
Drawer of fractal trees on Gtk# library Simple drawer for fractal trees on Gtk# library and Cairo OpenGL
# How to use: # How to use: