DEV Community

Cover image for Creating Fractals, Noise, Voronoi Patterns, and Gradients in Python with pyaitk.CLSE
Divyanshu Sinha
Divyanshu Sinha

Posted on

Creating Fractals, Noise, Voronoi Patterns, and Gradients in Python with pyaitk.CLSE

Procedural graphics are everywhere.

They're used in:

  • Game development
  • Scientific visualization
  • AI dataset generation
  • Generative art
  • Simulations
  • Digital design tools

Traditionally, creating fractals, noise maps, Voronoi diagrams, and advanced gradients requires multiple libraries or a significant amount of custom code.

But with pyaitk.CLSE, many of these techniques are available through simple, high-level APIs.

In this article, we'll explore how to generate fractals, procedural textures, and gradients using just a few lines of Python.


Mandelbrot Set

The Mandelbrot Set is one of the most famous fractals in mathematics.

With CLSE, generating one is straightforward:

from pyaitk.CLSE import ProceduralArt

img = ProceduralArt.mandelbrot_set(
    width=800,
    height=600
)

img.save("mandelbrot.png")
Enter fullscreen mode Exit fullscreen mode

The result is a detailed fractal image generated entirely through mathematical iteration.

Applications include:

  • Mathematical visualization
  • Educational software
  • Fractal exploration tools
  • Procedural artwork

Julia Sets

Julia Sets are closely related to the Mandelbrot Set but produce dramatically different structures depending on the selected complex constant.

img = ProceduralArt.julia_set(
    800,
    600,
    c_real=-0.7,
    c_imag=0.27015
)

img.save("julia.png")
Enter fullscreen mode Exit fullscreen mode

Changing the values of c_real and c_imag creates entirely new fractal worlds.

This makes Julia Sets particularly popular for:

  • Generative art
  • Animation
  • Mathematical experimentation
  • Visual effects

Sierpinski Triangle

The Sierpinski Triangle is a classic recursive fractal.

img = ProceduralArt.sierpinski_triangle(
    512,
    512,
    depth=7
)

img.save("sierpinski.png")
Enter fullscreen mode Exit fullscreen mode

Despite its simple construction rules, the resulting structure demonstrates self-similarity at multiple scales.

Common uses include:

  • Fractal education
  • Recursive graphics
  • Computational geometry demonstrations

Plasma Generation

Procedural plasma effects create smooth, colorful organic patterns.

img = ProceduralArt.plasma(
    512,
    512
)

img.save("plasma.png")
Enter fullscreen mode Exit fullscreen mode

Plasma textures are often used for:

  • Fantasy effects
  • Energy fields
  • Abstract backgrounds
  • Procedural artwork

Because the image is mathematically generated, every output can be unique.


Voronoi Diagrams

Voronoi diagrams divide space into regions based on distance from seed points.

img = ProceduralArt.voronoi(
    512,
    512,
    n_cells=25,
    seed=42
)

img.save("voronoi.png")
Enter fullscreen mode Exit fullscreen mode

The generated regions resemble:

  • Cellular structures
  • Cracked surfaces
  • Geographic partitioning
  • Natural growth patterns

Voronoi diagrams are widely used in:

  • Terrain generation
  • Game maps
  • Biology simulations
  • Procedural environments

Perlin Noise

Perlin Noise is one of the most important algorithms in procedural generation.

img = ProceduralArt.perlin_noise_image(
    512,
    512,
    octaves=4
)

img.save("perlin.png")
Enter fullscreen mode Exit fullscreen mode

Perlin Noise serves as the foundation for many procedural systems.

Applications include:

  • Terrain generation
  • Cloud rendering
  • Water simulation
  • Texture synthesis
  • AI dataset creation

The octaves parameter controls detail complexity.

Higher values produce richer structures.


Linear Gradients

Gradients are fundamental building blocks for many graphics workflows.

Creating a smooth linear gradient is simple:

from pyaitk.CLSE import VisualEffects

img = VisualEffects.create_linear_gradient(
    512,
    512,
    (70, 130, 200),
    (200, 80, 120)
)

img.save("linear_gradient.png")
Enter fullscreen mode Exit fullscreen mode

This smoothly blends one colour into another across the image.

Common uses include:

  • UI backgrounds
  • Data visualization
  • Procedural textures
  • Design assets

Radial Gradients

Radial gradients create colour transitions radiating outward from a central point.

img = VisualEffects.create_radial_gradient(
    512,
    512,
    (255, 220, 50),
    (30, 30, 120)
)

img.save("radial_gradient.png")
Enter fullscreen mode Exit fullscreen mode

This technique is useful for:

  • Lighting effects
  • Glow effects
  • Planet rendering
  • Artistic compositions

Combining Techniques

One of the strengths of CLSE is that these generators can be combined.

For example:

noise = ProceduralArt.perlin_noise_image(
    1024,
    1024,
    octaves=6
)

gradient = VisualEffects.create_radial_gradient(
    1024,
    1024,
    (255, 200, 50),
    (20, 20, 80)
)
Enter fullscreen mode Exit fullscreen mode

These outputs can be blended, transformed, filtered, or streamed into larger rendering pipelines.

This enables developers to create highly complex procedural graphics from simple building blocks.


Why This Matters

Many procedural graphics workflows require multiple libraries, custom implementations, or hundreds of lines of code.

CLSE provides ready-to-use generators for:

  • Mandelbrot Fractals
  • Julia Sets
  • Sierpinski Triangles
  • Plasma Effects
  • Voronoi Diagrams
  • Perlin Noise
  • Linear Gradients
  • Radial Gradients

all through a consistent API.

This makes experimentation faster and lowers the barrier to creating advanced procedural imagery.


Final Thoughts

Procedural generation is one of the most powerful techniques in computer graphics.

With just a few function calls, pyaitk.CLSE can generate fractals, noise maps, cellular structures, and professional-looking gradients entirely from mathematics.

Whether you're building games, creating AI datasets, generating textures, producing educational visualizations, or simply exploring generative art, CLSE provides a practical toolkit for creating images from code.

And perhaps the most interesting part?

Every image starts from pure algorithms—no external assets required.

Top comments (0)