#Excel VBA, 251 246 bytes
Saved 5 bytes thanks to ceilingcat
Sub m()
D=99
For x=1To 4*D
For y=1To 4*D
p=0
q=0
For j=1To 98
c=2*p*q
p=p^2-q^2-2+(x-1)/D
q=c+2+(1-y)/D
If p^2+q^2>=4Then Exit For
Next
j=-j*(j<99)
Cells(y,x).Interior.Color=Rnd(-j)*2^20*j/D
Next
Next
Cells.RowHeight=9
Cells.ColumnWidth=1
End Sub
Output:
I made a version that did this a long time ago but it had a lot of extras like letting the user pick the basic color and easy-to-follow math. Golfing it way down was an interesting challenge. The Color
method uses 2^20
as a means to get a wide range of colors since the valid colors are 0
to 2^24
. Setting the exponent to 20
gave higher contrast areas.
Explanation / Auto-Formatting:
Sub m()
'D determines the number of pixels and is factored in a few times throughout
D = 99
For x = 1 To 4 * D
For y = 1 To 4 * D
'Test to see if it escapes
'Use p for the real part and q for the imaginary
p = 0
q = 0
For j = 1 To 98
'This is a golfed down version of complex number math that started as separate generic functions for add, multiple, and modulus
c = 2 * p * q
p = p ^ 2 - q ^ 2 - 2 + (x - 1) / D
q = c + 2 + (1 - y) / D
If p ^ 2 + q ^ 2 >= 4 Then Exit For
Next
'Correct for no escape
j = -j * (j < 99)
'Store the results
'Rnd() with a negative input is deterministic
'This is what gives us the distinct color bands
Cells(y, x).Interior.Color = Rnd(-j) * 2 ^ 24 * j / D
Next
Next
'Resize for pixel art
Cells.RowHeight = 9
Cells.ColumnWidth = 1
End Sub
I also played around with D=999
and j=1 to 998
to get a much larger and more precise image. The results are irrelevant to the challenge because they're way too large but they are neat.