Skip to main content
Commonmark migration
Source Link

#Excel VBA, 251 246 224 223 221 bytes

Excel VBA, 251 246 224 223 221 bytes

#Excel VBA, 251 246 224 223 221 bytes

Excel VBA, 251 246 224 223 221 bytes

Shaved two bytes with `Next y,x`
Source Link
Engineer Toast
  • 9.5k
  • 1
  • 23
  • 53

#Excel VBA, 251 246 224 223223 221 bytes

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<D)
Cells(y,x).Interior.Color=Rnd(-j)*1E6*j/D
Next
Next y,x
Cells.RowHeight=48
End Sub
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 < D)
            
            '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) * 1000000# * j / D
            
        Next
   x, Nexty
    
    'Resize for pixel art
    Cells.RowHeight = 48
    
End Sub

#Excel VBA, 251 246 224 223 bytes

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<D)
Cells(y,x).Interior.Color=Rnd(-j)*1E6*j/D
Next
Next
Cells.RowHeight=48
End Sub
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 < D)
            
            '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) * 1000000# * j / D
            
        Next
    Next
    
    'Resize for pixel art
    Cells.RowHeight = 48
    
End Sub

#Excel VBA, 251 246 224 223 221 bytes

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<D)
Cells(y,x).Interior.Color=Rnd(-j)*1E6*j/D
Next y,x
Cells.RowHeight=48
End Sub
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 < D)

        '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) * 1000000# * j / D

    Next x, y

    'Resize for pixel art
    Cells.RowHeight = 48

End Sub
Saved one whole byte!
Source Link
Engineer Toast
  • 9.5k
  • 1
  • 23
  • 53

#Excel VBA, 251 246 224224 223 bytes

Saved 5 bytes thanks to ceilingcat Saved 2223 bytes thanks to Taylor Scott

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<D)
Cells(y,x).Interior.Color=Rnd(-j)*2^20*j*1E6*j/D
Next
Next
Cells.RowHeight=48
End Sub

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^201E6 as a means to get a wide range of colors since the valid colors are 0 to 2^24. Setting the exponentit to 2010^6 gave highernice contrast areas.

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 < D)
            
            '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 ^ 241000000# * j / D
            
        Next
    Next
    
    'Resize for pixel art
    Cells.RowHeight = 48
    
End Sub

#Excel VBA, 251 246 224 bytes

Saved 5 bytes thanks to ceilingcat Saved 22 bytes thanks to Taylor Scott

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<D)
Cells(y,x).Interior.Color=Rnd(-j)*2^20*j/D
Next
Next
Cells.RowHeight=48
End Sub

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.

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 < D)
            
            '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 = 48
    
End Sub

#Excel VBA, 251 246 224 223 bytes

Saved 5 bytes thanks to ceilingcat Saved 23 bytes thanks to Taylor Scott

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<D)
Cells(y,x).Interior.Color=Rnd(-j)*1E6*j/D
Next
Next
Cells.RowHeight=48
End Sub

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 1E6 as a means to get a wide range of colors since the valid colors are 0 to 2^24. Setting it to 10^6 gave nice contrast areas.

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 < D)
            
            '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) * 1000000# * j / D
            
        Next
    Next
    
    'Resize for pixel art
    Cells.RowHeight = 48
    
End Sub
Saved more bytes
Source Link
Engineer Toast
  • 9.5k
  • 1
  • 23
  • 53
Loading
Saved 5 bytes
Source Link
Engineer Toast
  • 9.5k
  • 1
  • 23
  • 53
Loading
Source Link
Engineer Toast
  • 9.5k
  • 1
  • 23
  • 53
Loading