diff options
author | Brett Weiland <brett_weiland@gmail.com> | 2024-06-11 14:50:14 -0500 |
---|---|---|
committer | Brett Weiland <brett_weiland@gmail.com> | 2024-06-11 14:50:14 -0500 |
commit | cb69732f68c0bd46c1574de16ce1aee6f38e439b (patch) | |
tree | def1daaec81a0d4cd7b3d44b2c26b9535e07579c /polar/notes |
Diffstat (limited to 'polar/notes')
-rw-r--r-- | polar/notes | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/polar/notes b/polar/notes new file mode 100644 index 0000000..50249d7 --- /dev/null +++ b/polar/notes @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import pyopencl as cl +from alive_progress import alive_bar + +img_res_x = 2000 +img_res_y = 2000 +total_pixels = img_res_x * img_res_y # so we don't gotta compute it every time + +periods = 1 +square_x = 0 +square_y = 0 + +xmin = (-periods * np.pi) + (square_x * np.pi) +xmax = (periods * np.pi) + (square_x * np.pi) +ymin = (-periods * np.pi) + (square_y * np.pi) +ymax = (periods * np.pi) + (square_y * np.pi) + +escape = 10000 +iterations = 255*3 +c_x = 2 * np.pi +c_y = 2 * np.pi + +animation_progres_save = "./animations" +frames = 120 + +rendered_frames = [] + + +plt.style.use('dark_background') +# fuck this shit +fig = plt.figure(frameon=False) +fig.set_size_inches(img_res_x/fig.dpi, img_res_y/fig.dpi) +#fig.set_size_inches(width/height, 1, forward=False) + +ax = plt.Axes(fig, [0., 0., 1., 1.]) +ax.set_axis_off() +fig.add_axes(ax) + +cmap = plt.cm.viridis +cmap.set_bad((0,0,0)) +cmap.set_over((0,0,0)) +cmap.set_under((0,0,0)) + +opencl_context = cl.create_some_context() +opencl_queue = cl.CommandQueue(opencl_context) + + +#def render(): +# image = np.empty([img_res_y, img_res_x]) +# print("Rendering frames") +# with alive_bar(frames, bar = 'filling', spinner = 'waves') as bar_total: +# for frame in range(frames): +# split_ratio = frame / frames +# for pix_y, y in enumerate(np.linspace(ymin, ymax, img_res_y)): +# for pix_x, x in enumerate(np.linspace(xmin, xmax, img_res_x)): +# on_x = x +# on_y = y +# for i in range(iterations): +# next_x = (split_ratio * (on_x/np.sin(on_y))) + ((1 - split_ratio) * on_x/np.tan(on_y)) +# on_y = (split_ratio * (on_y/np.sin(on_x))) + ((1 - split_ratio) * on_y/np.tan(on_x)) +# on_x = next_x +# if on_x**2 + on_y**2 > escape: +# break +# image[pix_y][pix_x] = i +# rendered_frame = ax.imshow(image, norm="log", aspect="auto", cmap=cmap, animated=False) +# rendered_frames.append([rendered_frame]) +# bar_total() + +def display(): + print(rendered_frames) + ani = animation.ArtistAnimation(fig, rendered_frames, interval=30, blit=True) + ani.save("test.mp4") + plt.show() + +render() +display() |