MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / draw_fractal_recursive

Function draw_fractal_recursive

fractals/vicsek.py:37–50  ·  view source on GitHub ↗

Recursively draw the Vicsek fractal at the specified position, with the specified length and depth.

(x: float, y: float, length: float, depth: float)

Source from the content-addressed store, hash-verified

35
36
37def draw_fractal_recursive(x: float, y: float, length: float, depth: float):
38 """
39 Recursively draw the Vicsek fractal at the specified position, with the
40 specified length and depth.
41 """
42 if depth == 0:
43 draw_cross(x, y, length)
44 return
45
46 draw_fractal_recursive(x, y, length / 3, depth - 1)
47 draw_fractal_recursive(x + length / 3, y, length / 3, depth - 1)
48 draw_fractal_recursive(x - length / 3, y, length / 3, depth - 1)
49 draw_fractal_recursive(x, y + length / 3, length / 3, depth - 1)
50 draw_fractal_recursive(x, y - length / 3, length / 3, depth - 1)
51
52
53def set_color(rgb: str):

Callers 1

draw_vicsek_fractalFunction · 0.85

Calls 1

draw_crossFunction · 0.85

Tested by

no test coverage detected