Skip to content

Commit ceef97b

Browse files
Update kececifractals.py
1 parent e2c5f20 commit ceef97b

File tree

1 file changed

+115
-3
lines changed

1 file changed

+115
-3
lines changed

kececifractals/kececifractals.py

Lines changed: 115 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ def kececi_layout(
4040
pos[node] = (i * primary_spacing, i * secondary_spacing)
4141
return pos
4242

43+
HIGH_CONTRAST_COLORS = [
44+
(1.0, 1.0, 1.0), # Camgöbeği
45+
(1.0, 0.0, 1.0), # Magenta
46+
(1.0, 1.0, 0.0), # Sarı
47+
(0.0, 1.0, 0.0), # Yeşil
48+
(1.0, 0.0, 0.0), # Kırmızı
49+
(0.0, 0.0, 1.0), # Mavi
50+
(1.0, 0.5, 0.0), # Turuncu
51+
]
4352

4453
class KececiFractalError(Exception):
4554
"""Keçeci Fractals için temel exception."""
@@ -1714,7 +1723,6 @@ def generate_fractal_directly(ax, config: dict):
17141723
ax.set_zlim([-max_extent, max_extent])
17151724
ax.view_init(elev=25, azim=45)
17161725

1717-
17181726
def generate_simple_3d_fractal(
17191727
ax,
17201728
num_children: int = 6,
@@ -1914,12 +1922,116 @@ def generate_simple_3d_fractal(
19141922
ax.set_yticks([])
19151923
ax.set_zticks([])
19161924

1925+
def draw_kececi_internal_fractal_3d(
1926+
ax,
1927+
center=(0, 0, 0),
1928+
radius=1.0,
1929+
depth=3,
1930+
num_children=8,
1931+
scale_factor=0.4,
1932+
min_radius=0.02,
1933+
current_depth=0
1934+
):
1935+
"""
1936+
🌀 3D Keçeci Internal Fractal – Belirgin Renk Ayrımı ile
1937+
1938+
Çocuk küreler, ebeveyn kürenin İÇ yüzeyine teğet olacak şekilde yerleştirilir.
1939+
Her seviye sabit, kontrastlı bir renkle gösterilir.
1940+
"""
1941+
if depth < 0 or radius < min_radius:
1942+
return
1943+
1944+
# Sabit, belirgin renk paleti (derinliğe göre)
1945+
color_palette = [
1946+
(0.9, 0.2, 0.2), # depth 0: kırmızı (merkez)
1947+
(0.9, 0.6, 0.2), # depth 1: turuncu
1948+
(0.9, 0.9, 0.2), # depth 2: sarı
1949+
(0.2, 0.9, 0.4), # depth 3: yeşil
1950+
(0.0, 0.8, 0.9), # depth 4: turkuaz
1951+
(0.3, 0.3, 0.9), # depth 5: mavi
1952+
(0.6, 0.2, 0.8), # depth 6: mor
1953+
]
1954+
color = color_palette[current_depth % len(color_palette)]
1955+
1956+
# Ana küreyi çiz
1957+
draw_sphere(
1958+
ax,
1959+
center=center,
1960+
radius=radius,
1961+
color=color,
1962+
alpha=0.7 + 0.05 * current_depth, # iç katmanlar daha az saydam
1963+
edgecolor='none'
1964+
)
1965+
1966+
if depth == 0:
1967+
return
1968+
1969+
# Çocuk küreler: ebeveynin İÇİNE, iç yüzeye teğet
1970+
child_radius = radius * scale_factor
1971+
directions = get_icosahedron_vertices()[:num_children]
1972+
# Merkezden mesafe = R_ebeveyn - R_çocuk → iç teğet
1973+
distance_from_center = radius - child_radius
1974+
1975+
for d in directions:
1976+
child_center = np.array(center) + distance_from_center * d
1977+
draw_kececi_internal_fractal_3d(
1978+
ax,
1979+
center=tuple(child_center),
1980+
radius=child_radius,
1981+
depth=depth - 1,
1982+
num_children=num_children,
1983+
scale_factor=scale_factor,
1984+
min_radius=min_radius,
1985+
current_depth=current_depth + 1
1986+
)
1987+
1988+
def draw_kececi_internal_fractal_3d(
1989+
ax,
1990+
center=(0, 0, 0),
1991+
radius=1.0,
1992+
depth=3,
1993+
num_children=8,
1994+
scale_factor=0.4,
1995+
min_radius=0.02,
1996+
current_depth=0
1997+
):
1998+
if depth < 0 or radius < min_radius:
1999+
return
2000+
2001+
color = HIGH_CONTRAST_COLORS[current_depth % len(HIGH_CONTRAST_COLORS)]
2002+
2003+
draw_sphere(
2004+
ax,
2005+
center=center,
2006+
radius=radius,
2007+
color=color,
2008+
alpha=0.30,
2009+
edgecolor='none'
2010+
)
2011+
2012+
if depth == 0:
2013+
return
2014+
2015+
child_radius = radius * scale_factor
2016+
directions = get_icosahedron_vertices()[:num_children]
2017+
distance_from_center = radius - child_radius
2018+
2019+
for d in directions:
2020+
child_center = np.array(center) + distance_from_center * d
2021+
draw_kececi_internal_fractal_3d(
2022+
ax,
2023+
center=tuple(child_center),
2024+
radius=child_radius,
2025+
depth=depth - 1,
2026+
num_children=num_children,
2027+
scale_factor=scale_factor,
2028+
min_radius=min_radius,
2029+
current_depth=current_depth + 1
2030+
)
19172031

19182032
# ==============================================================================
19192033
# ÖRNEK KULLANIM FONKSİYONLARI (isteğe bağlı) - DÜZELTİLMİŞ
19202034
# ==============================================================================
1921-
1922-
19232035
def example_multiple_fractals():
19242036
"""
19252037
Çoklu fraktal karşılaştırması örneği.

0 commit comments

Comments
 (0)