This commit is contained in:
Савелій Савёнак
2023-01-30 00:24:30 +03:00
parent 17db4dc996
commit 4c25bc17af
2 changed files with 46 additions and 23 deletions

View File

@@ -7,31 +7,36 @@ namespace FractalTreeGtk.Draw
{
internal class Fractal
{
public bool Drawing = true;
CairoWindow window;
double Length = 100;
double MainDegree = 0.4;
int levels;
int level = 0;
double deltaLength = 5;
public Branch[][] Fractallines;
public Fractal(int levels)
public Fractal(int levels, CairoWindow window)
{
this.levels = levels;
Fractallines = new Branch[levels + 1][];
CreateBranch();
this.window = window;
this.levels = levels;
Fractallines = new Branch[levels + 1][];
CreateBranch();
}
private void CreateBranch()
{
Fractallines[level] = new Branch[Convert.ToInt32(Math.Pow(2, level))];
for (int i = 0; i < Fractallines[level].Length; i++)
{
Fractallines[level][i] = new Branch(0, 0, 0, -Length, true, 0);
}
level++;
NextLevel();
Fractallines[level] = new Branch[Convert.ToInt32(Math.Pow(2, level))];
for (int i = 0; i < Fractallines[level].Length; i++)
{
Fractallines[level][i] = new Branch(0, 0, 0, -Length, true, 0);
}
level++;
NextLevel();
}
private void NextLevel()
{
window.QueueDraw();
Length -= deltaLength;
window.QueueDraw();
Fractallines[level] = new Branch[Convert.ToInt32(Math.Pow(2, level))];
int x = 0;
for (int i = 0; i < Fractallines[level - 1].Length; i++)
@@ -82,6 +87,7 @@ namespace FractalTreeGtk.Draw
{
NextLevel();
}
else Drawing = false;
}
//private int SumOfBranches()
//{