MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / julia

Function julia

24_raster_graphics/python/thumbnails.py:6–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6def julia():
7 imgx = 800
8 imgy = 800
9
10 scalex = 3.0 / imgx
11 scaley = 3.0 / imgy
12
13 imgbuf = np.zeros((imgx, imgy, 3), dtype=np.uint8)
14 for i in np.ndindex(imgbuf.shape[:2]):
15 y, x = i
16 r = (0.3 * x)
17 b = (0.3 * y)
18 cx = float(y) * scalex - 1.5
19 cy = float(x) * scaley - 1.5
20 c = complex(-0.4, 0.6)
21 z = complex(cx, cy)
22
23 g = 0
24 while g < 255 and np.hypot(z.real, z.imag) <= 2.0:
25 z = z * z + c
26 g += 1
27 imgbuf[i] = [r, g, b]
28
29 im = Image.fromarray(imgbuf, 'RGB')
30 im.save("fractal.png")
31
32
33if __name__ == "__main__":

Callers 1

thumbnails.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected