Godot Nature of Code  1.2.0
Nature of Code implemented in Godot Engine
Public Member Functions | List of all members
Fractals.CantorSet Class Reference

Cantor set. More...

Public Member Functions

 CantorSet (Vector2 start, Vector2 end, int generations, float separation)
 Create new cantor set. More...
 
void GenerateOne ()
 Generate one generation. More...
 
void GenerateAll ()
 Generate all needed generations. More...
 
void Draw (CanvasItem canvas)
 Draw set using canvas. More...
 

Detailed Description

Cantor set.

Definition at line 61 of file CantorSet.cs.

Constructor & Destructor Documentation

◆ CantorSet()

Fractals.CantorSet.CantorSet ( Vector2  start,
Vector2  end,
int  generations,
float  separation 
)
inline

Create new cantor set.

Parameters
startStarting point.
endEnding point.
generationsGeneration count.
separationSeparation.

Definition at line 74 of file CantorSet.cs.

75  {
76  _generations = generations;
77  _separation = separation;
78 
79  _lines.Add(new List<CantorLine>() {
80  new CantorLine() {
81  Start = start,
82  End = end
83  }
84  });
85  }

Member Function Documentation

◆ Draw()

void Fractals.CantorSet.Draw ( CanvasItem  canvas)
inline

Draw set using canvas.

Parameters
canvasCanvas item

Definition at line 129 of file CantorSet.cs.

130  {
131  foreach (var lineArray in _lines)
132  {
133  foreach (var line in lineArray)
134  line.Draw(canvas);
135  }
136  }

◆ GenerateAll()

void Fractals.CantorSet.GenerateAll ( )
inline

Generate all needed generations.

Definition at line 119 of file CantorSet.cs.

120  {
121  for (var i = 0; i < _generations; ++i)
122  GenerateOne();
123  }
void GenerateOne()
Generate one generation.
Definition: CantorSet.cs:90

◆ GenerateOne()

void Fractals.CantorSet.GenerateOne ( )
inline

Generate one generation.

Definition at line 90 of file CantorSet.cs.

91  {
92  var next = new List<CantorLine>();
93 
94  foreach (var line in _lines[^1])
95  {
96  var a = line.PointA() + new Vector2(0, _separation);
97  var b = line.PointB() + new Vector2(0, _separation);
98  var c = line.PointC() + new Vector2(0, _separation);
99  var d = line.PointD() + new Vector2(0, _separation);
100 
101  next.Add(new CantorLine()
102  {
103  Start = a,
104  End = b
105  });
106  next.Add(new CantorLine()
107  {
108  Start = c,
109  End = d
110  });
111  }
112 
113  _lines.Add(next);
114  }

The documentation for this class was generated from the following file: