Skip to main content

FractalGen is a python fractal generating library usings IFS

Project description

FractalGen

Fractal-gen is a open library which can be used to generate, experiment and create fractal images using IFS'. IFS' are Iterated Function Systems which are used in one of the methods in constructing fractals. IFS' are simply set of Affine equations upon which we apply different algorithms to generate fractal images. For further more detailed explanation on IFS' and their workings we recommend users to go through these links below:

Out of many algorithms which generate fractals, our library generates fractals based on Deterministic and Random Iteration algorithms. There are notaions of affine transformations for iterated functions systems (IFS) which are as follows:

and and

Out of all the most used notation is the third one. Many IFSs are available in similar format to the 3 notation or they can be derived from different forms to the 3rd one some of mostly used notations are below

Capture

Deterministic:

Tabular representation of values a, b, c, d, e, f of 4 Affine transformations.

a b c d e f
set 1 0.01 0 0 0.45 0 0
set 2 -0.01 0 0 -0.45 0 0.4
set 3 0.42 -0.42 0.42 0.42 0 0.4
set 4 0.42 0.42 -0.42 0.42 0 0.4

random iteration:

Tabular representation of values a, b, c, d, e, f, p of 4 Affine transformations.

a b c d e f probability
set 1 0 0 0 0.16 0 0 0.01
set 2 0.2 -0.26 0.23 0.22 0 1.6 0.07
set 3 -0.15 0.28 0.26 0.24 0 0.44 0.07
set 4 0.85 0.04 -0.04 0.85 0 1.6 0.85

So all the details we need to generate fractal image are values of a, b, c, d, e, f of an affine traformation in a IFS while using deterministic algorithm and probabilities in addition while using random iteration algorithm. We recommend users to get a good picture on working of IFS' and representations of IFSs before continuing further.

How to use

How to create a IFS object and adding eqns.

ifs_obj = Ifs()
lst = [
    [0, 0, 0, 0.16, 0, 0, 0.01], # => [a, b, c, d, e, f, p]
    [0.85, 0.04, -0.04, 0.85, 0, 1.60, 0.85],
    [0.20, -0.26, 0.23, 0.22, 0, 1.60, 0.07],
    [-0.15, 0.28, 0.26, 0.24, 0, 0.44, 0.07],
]

ifs_obj.AddEquations(lst) # Length of all eqns should be equal. Length 7 of random iteration.
                          # length 6 for deterministic.

Printing IFS object.

print(ifs_obj)

# equation = 1: [[a = 0.0 b = 0.0]   [[e = 0]  p=0.01
# 	         [c = 0.0 d = 0.16]]  [f = 0]]

# equation = 2: [[a = 0.85 b = 0.04]   [[e = 0.0]  p=0.85
# 	         [c = -0.04 d = 0.85]]  [f = 1.6]]

# equation = 3: [[a = 0.2 b = -0.26]   [[e = 0.0]  p=0.07
# 	         [c = 0.23 d = 0.22]]  [f = 1.6]]

# equation = 4: [[a = -0.15 b = 0.28]   [[e = 0.0]  p=0.07
#  	         [c = 0.26 d = 0.24]]   [f = 0.44]]

Running fractal generating algorithms.

ifs_obj.randomIteration(1_00_000) # Run 1,00,000 iterations.

# For using deterministic algorithm use the below.
ifs_obj.deterministic(Shape.square(), iteration) # deterministic takes Shape and number of iterations as arguments.
                                                 # You can use pre-defined Shape check out Shape class.
                                                 # As of now we have 200-300 points to generate a shape.

Plotting fractal image.

ifs_obj.plot()

Output fractal image.

  • Random iteration output:

  • Deteministic output:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FractalGen-1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file FractalGen-1.0-py3-none-any.whl.

File metadata

  • Download URL: FractalGen-1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for FractalGen-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f26aff8709002a1a330828f7385232f6e376d7c8c60707d0dc37b9ed453702ad
MD5 5e64075e54188a09b6c75b295f74453a
BLAKE2b-256 c165e3b2dc72342a1f804e3ea2944761deefc5a3a6abf8b834eefe306862931b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page