# Julia Fractal in Python

Python Methods and Functions

Equation for generating Julia's fractal:

where c — complex parameter. Julia's set for this system is a subset of the complex plane, defined as:

So, let's now try to create one of the fractals in the image above.

For this we need the Python module Pillow, which makes it easier to work with images and so on.

To install a pillow via pip, enter the following command at the command line.

` pip install Pillow `

Now use this library to create a fractal image.

Output:

Also refer to this video at phone number for more information.

After understanding the code, try drawing other fractals by changing the value of the variables and post your link to github in the code in the comments section and I'll be happy to help you if any error occurs.

This article is courtesy of Subhajit Saha . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.

Please post comments if you find anything wrong or if you'd like to share more information on the topic discussed above.

## Books for developers

 ` # Python code for Julia Fractal ` ` from ` ` PIL ` ` import ` ` Image `   ` # dra function ivera ` ` if ` ` __ name__ ` ` = ` ` = ` ` "__ main__" ` `: `   ` # adjust width, height and scale ` ` # image to be generated ` ` w, h, zoom ` ` = ` ` 1920 ` `, ` ` 1080 ` `, ` ` 1 `   ` # create a new RGB image ` ` ` ` bitmap ` ` = ` ` Image.new (` ` "RGB" ` `, (w, h), ` `" white "` `) `   ` # Allocate storage for the image and ` ` # load pixel data. ` ` pix ` ` = ` ` bitmap.load () `   ` # installation variables according to ` ` # equation for creating a fractal ` ` cX, cY ` ` = ` ` - ` ` 0.7 ` `, ` ` 0.27015 ` ` moveX, moveY ` ` = ` ` 0.0 ` `, ` ` 0.0 ` ` maxIter ` ` = ` ` 255 `   ` for ` ` x ` ` in ` ` range ` ` (w ): ` ` for ` ` y ` ` in ` ` range ` ` (h): ` ` zx ` ` = ` ` 1.5 ` ` * ` ` (x ` ` - ` ` w ` ` / ` ` 2 ` `) ` ` / ` ` (` ` 0.5 ` ` * ` ` zoom ` ` * ` ` w) ` ` + ` ` moveX ` ` zy ` ` = ` ` 1.0 ` ` * ` ` (y ` ` - ` ` h ` ` / ` ` 2 ` `) ` ` / ` ` (` ` 0.5 ` ` * ` ` zoom ` ` * ` ` h) ` ` + ` ` moveY ` ` i ` ` = ` ` maxIter ` ` ` ` while ` ` zx ` ` * ` ` zx ` ` + ` ` zy ` ` * ` ` zy & lt; ` ` 4 ` ` and ` ` i & gt; ` ` 1 ` `: ` ` tmp ` ` = ` ` zx ` ` * ` ` zx ` ` - ` ` zy ` ` * ` ` zy ` ` + ` ` cX ` ` zy, zx ` ` = ` ` 2.0 ` ` * ` ` zx ` ` * ` ` zy ` ` + ` ` cY, tmp ` ` i ` ` - ` ` = ` ` 1 `   ` ` ` # convert byte to RGB (3 bytes) like ` ` ` ` # magic to get nice colors ` ` pix [ x, y] ` ` = ` ` (i & lt; & lt; ` ` 21 ` `) ` ` + ` ` (i & lt; & lt; ` ` 10 ` `) ` ` + ` ` i ` ` * ` ` 8 `   ` # to display the created fractal ` ` bitmap.show () `