The process takes each point in the plane, and uses the given functions to iterate, until it comes back to its start point (or not!). The time it takes to do that determines the colour of the plot.The code runs happily in either BB4W or BBC-SDL - slightly quicker in the latter, I think, but not much in it.
D
Code: Select all
REM Gingerbreadman map
REM https://en.wikipedia.org/wiki/Gingerbreadman_map
REM Each point in the plane is taken, and iterated using the following rules:
REM x(n+1) = 1 - y(n) + ABS(x(n))
REM y(n+1) = x(n)
REM We count how many iterations it takes to get back to the start (capped at some depth limit)
REM Points are coloured by their cycle length.
REM Uncomment whichever of these you fancy... or choose your own values
min = -10:max = 10: depth = 1000: step = 0.125:sf = 4/step :REM keep step as a reciprocal of a power of 2
REM min = -12:max = 12: depth = 1000: step = 0.0625:sf = 4/step :REM keep step as a reciprocal of a power of 2
REM min = -15:max = 15: depth = 250: step = 0.125:sf = 4/step :REM keep step as a reciprocal of a power of 2
REM min = -20:max = 30: depth = 500: step = 0.125:sf = 4/step :REM keep step as a reciprocal of a power of 2
REM Define a custom mode into which the plot fits
VDU 23,22,sf*(max-min)/2 + 2;sf*(max-min)/2 + 2;16,16,16,0
GCOL 1
FOR x = min TO max STEP step
FOR y = min TO max STEP step
tx = x
ty = y
n = 0
c = 0
REPEAT
tx2 = 1 - ty + ABS(tx)
ty = tx
tx=tx2
n += 1
IF ABS(tx - x)<0.01 AND ABS(ty - y) < 0.01 THEN c = n
UNTIL c OR n = depth
REM Define a custom colour that covers a wide range of cycle lengths
COLOUR 1, (c MOD 16) * 16,(c MOD 64)*4,c MOD 255
PLOT 69,(x-min)*sf,(y-min)*sf
NEXT y
NEXT x
END