# This file is the main application file to host the application logic
# Importing gradio and the plot_julia_set function from funcs.py
import gradio as gr
from funcs import plot_julia_set
with gr.Blocks() as demo:
with gr.Row():
# Adding an application header
gr.Markdown("""
Julia Set Generator 🌌
Use this interactive tool to generate visualizations of Julia Sets!
Instructions:
- Input the Real and Imaginary parts of the complex number
c.
- Adjust the max iterations to control the detail and depth.
- Adjust the pixel density to control the resolution.
- Choose a colormap to customize the appearance.
- Click "Generate Plot" to render the image.
- For more info, see this GitHub repository.
""")
# Adding all the interactive components of the application
with gr.Column():
real = gr.Textbox(label = 'Real Part', value = '0', interactive = True)
imag = gr.Textbox(label = 'Imaginary Part', value = '0', interactive = True)
max_iter = gr.Slider(label = 'Specify the maximum number of iterations', minimum = 10, maximum = 2000, value = 500, step = 10, interactive = True)
pixel_density = gr.Slider(label = 'Specify pixel density', minimum = 0.5, maximum = 2.5, value = 1.0, step = 0.1, interactive = True)
colormap_choices = ['binary', 'inferno', 'magma', 'cividis', 'viridis', 'plasma', 'Pastel1', 'Pastel2', 'Paired', 'Accent', 'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern', 'rainbow', 'jet', 'turbo', 'gray', 'bone', 'pink', 'spring', 'summer', 'autumn', 'winter', 'cool', 'hot', 'copper']
cmap = gr.Dropdown(label = 'Choose colormap', choices = colormap_choices, value = 'binary', interactive = True)
submit = gr.Button('Generate Plot')
with gr.Row():
image = gr.Image(label = 'Julia Set', width = 600, height = 450, interactive = False)
submit.click(fn = plot_julia_set, inputs = [real, imag, max_iter, pixel_density, cmap], outputs = image)
demo.launch()