See the wikipedia page on the Mandelbrot Set

First a couple imports:

import cats.implicits._
import spire.implicits.DoubleAlgebra
import axle._
import axle.math._

Define a function to compute the Mandelbrot velocity at point on the plane (x, y)

val f = (x0: Double, x1: Double, y0: Double, y1: Double) => inMandelbrotSetAt(4d, x0, y0, 1000).getOrElse(-1)
// f: (Double, Double, Double, Double) => Int = <function4>

Import visualization package

import axle.visualize._

Define a “velocity to color” function

val colors = (0 to 255).map(g => Color(0, g, 255)).toArray
// colors: Array[axle.visualize.Color] = Array(Color(0,0,255), Color(0,1,255), Color(0,2,255), Color(0,3,255), Color(0,4,255), Color(0,5,255), Color(0,6,255), Color(0,7,255), Color(0,8,255), Color(0,9,255), Color(0,10,255), Color(0,11,255), Color(0,12,255), Color(0,13,255), Color(0,14,255), Color(0,15,255), Color(0,16,255), Color(0,17,255), Color(0,18,255), Color(0,19,255), Color(0,20,255), Color(0,21,255), Color(0,22,255), Color(0,23,255), Color(0,24,255), Color(0,25,255), Color(0,26,255), Color(0,27,255), Color(0,28,255), Color(0,29,255), Color(0,30,255), Color(0,31,255), Color(0,32,255), Color(0,33,255), Color(0,34,255), Color(0,35,255), Color(0,36,255), Color(0,37,255), Color(0,38,255), Color(0,39,255), Color(0,40,255), Color(0,41,255), Color(0,42,255), Color(0,43,255), Color(0,44,255)...

val v2c = (v: Int) => if( v == -1 ) Color.black else colors((v*5) % 256)
// v2c: Int => axle.visualize.Color = <function1>

Define a PixelatedColoredArea to show a range of the Mandelbrot Set.

val pca = PixelatedColoredArea(f, v2c, 400, 400, 0.25d, 0.45, 0.50, 0.70d)
// pca: axle.visualize.PixelatedColoredArea[Double,Double,Int] = PixelatedColoredArea(<function4>,<function1>,400,400,0.25,0.45,0.5,0.7)

Create PNG

import axle.awt._
// import axle.awt._

png(pca, "mandelbrot.png")

Mandelbrot Set

Some other parts of the set to explore:

val pca = PixelatedColoredArea(f, v2c, 1600, 1600, 0d, 1d, 0d, 1d)

val pca = PixelatedColoredArea(f, v2c, 1600, 1600, 0d, 0.5, 0.5, 1d)

val pca = PixelatedColoredArea(f, v2c, 1600, 1600, 0.25d, 0.5, 0.5, 0.75d)

val pca = PixelatedColoredArea(f, v2c, 3000, 3000, 0.20d, 0.45, 0.45, 0.70d)