{"spec_id":"heatmap-mandelbrot","library":"makie","language":"julia","code":"# anyplot.ai\n# heatmap-mandelbrot: Mandelbrot Set Fractal Visualization\n# Library: makie 0.22.10 | Julia 1.11.9\n# Quality: 89/100 | Created: 2026-05-30\n\nusing CairoMakie\nusing Colors\n\n# Theme tokens (Imprint palette — theme-adaptive chrome)\nconst THEME       = get(ENV, \"ANYPLOT_THEME\", \"light\")\nconst PAGE_BG     = THEME == \"light\" ? colorant\"#FAF8F1\" : colorant\"#1A1A17\"\nconst ELEVATED_BG = THEME == \"light\" ? colorant\"#FFFDF6\" : colorant\"#242420\"\nconst INK         = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nconst INK_SOFT    = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\n\n# Imprint sequential colormap: brand green → blue (single-polarity continuous data)\nconst ANYPLOT_SEQ = cgrad([colorant\"#009E73\", colorant\"#4467A3\"])\n\n# Interior of the Mandelbrot set: near-black (canonical convention, never escapes)\nconst INTERIOR_COLOR = colorant\"#0A0A0A\"\n\n# Mandelbrot parameters\nconst X_MIN    = -2.5\nconst X_MAX    =  1.0\nconst Y_MIN    = -1.25\nconst Y_MAX    =  1.25\nconst MAX_ITER = 256\nconst WIDTH    = 1600\nconst HEIGHT   =  900\n\n# Compute smooth escape count for each pixel\nxs = range(X_MIN, X_MAX; length = WIDTH)\nys = range(Y_MIN, Y_MAX; length = HEIGHT)\nescape = Matrix{Float64}(undef, WIDTH, HEIGHT)\n\nfor i in 1:WIDTH, j in 1:HEIGHT\n    cx = xs[i]\n    cy = ys[j]\n    zx = 0.0\n    zy = 0.0\n    iter = 0\n    escaped = false\n    while iter < MAX_ITER\n        zx2 = zx * zx\n        zy2 = zy * zy\n        if zx2 + zy2 > 4.0\n            escaped = true\n            break\n        end\n        zy = 2.0 * zx * zy + cy\n        zx = zx2 - zy2 + cx\n        iter += 1\n    end\n    if escaped\n        zmod = sqrt(zx * zx + zy * zy)\n        smooth = iter + 1.0 - log2(log2(zmod))\n        escape[i, j] = mod(smooth, 8.0) / 8.0\n    else\n        escape[i, j] = NaN\n    end\nend\n\n# Figure\nfig = Figure(\n    size            = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title              = \"heatmap-mandelbrot · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    xlabel             = \"Re(c)\",\n    ylabel             = \"Im(c)\",\n    xlabelsize         = 14,\n    ylabelsize         = 14,\n    xlabelcolor        = INK,\n    ylabelcolor        = INK,\n    xticklabelsize     = 12,\n    yticklabelsize     = 12,\n    xticklabelcolor    = INK_SOFT,\n    yticklabelcolor    = INK_SOFT,\n    xtickcolor         = INK_SOFT,\n    ytickcolor         = INK_SOFT,\n    leftspinecolor     = INK_SOFT,\n    bottomspinecolor   = INK_SOFT,\n    topspinevisible    = false,\n    rightspinevisible  = false,\n    xgridvisible       = false,\n    ygridvisible       = false,\n    backgroundcolor    = PAGE_BG,\n    aspect             = DataAspect(),\n)\n\nhm = heatmap!(ax, xs, ys, escape;\n    colormap   = ANYPLOT_SEQ,\n    nan_color  = INTERIOR_COLOR,\n    colorrange = (0.0, 1.0),\n)\n\nColorbar(fig[1, 2], hm;\n    label          = \"Escape speed\",\n    labelsize      = 12,\n    labelcolor     = INK,\n    ticklabelsize  = 10,\n    ticklabelcolor = INK_SOFT,\n    tickcolor      = INK_SOFT,\n    width          = 16,\n)\n\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}