Julia set: Difference between revisions
→Vectorized: Improved algorithm - >3 times faster
m (→Vectorized) |
(→Vectorized: Improved algorithm - >3 times faster) |
||
Line 1,451:
[https://imgur.com/a/o3j9Zzn Example output.]
<lang python>"""
Solution from:
https://codereview.stackexchange.com/questions/210271/generating-julia-set
"""
from functools import partial
Line 1,493 ⟶ 1,491:
:return: 2D pixels array of intensities
"""
z = (re + 1j * im).flatten()
▲ min_coordinate.real: max_coordinate.real: width * 1j]
iterations = np.empty_like(z, dtype=int)
for
iterations[live[escaped]] = i
live = live[~escaped]
if live.size == 0:
break
else:
return
Line 1,521 ⟶ 1,522:
plt.axis('off')
plt.imshow(image,
cmap='
origin='lower')
plt.show()
|