Just a tiny change for origin of gradient fill for the original code.
_TITLE "Rainbow Circle" 'B+ 2019-10-30 trans from JB
CONST xmax = 700, ymax = 700, pi = _PI, cx = xmax / 2, cy = ymax / 2, radius = 325
SCREEN _NEWIMAGE(xmax, ymax, 32)
_SCREENMOVE 400, 20
f! = .5 '* the fraction of the circle to fill in with a gradient -- tiny mod by CodeGuy
Rotate! = pi / 2
FOR a = 0 TO (2 * pi) * f! STEP 1 / radius
x1 = cx + radius * COS(a - Rotate!): y1 = cy + radius * SIN(a - Rotate!)
thic cx, cy, x1, y1, 2, rainbow~&(a / (2 * pi))
NEXT
SLEEP
FUNCTION rainbow~& (fraction)
radians = fraction * 2 * pi
r = SIN(radians) * 127 + 128
g = SIN(radians - 2 / 3 * pi) * 127 + 128
b = SIN(radians + 2 / 3 * pi) * 127 + 128
rainbow~& = _RGB32(r, g, b)
END FUNCTION
SUB thic (x1, y1, x2, y2, thick, K AS _UNSIGNED LONG) 'thick lines
PD2 = pi / 2
DIM t2 AS SINGLE, a AS SINGLE, x3 AS SINGLE, y3 AS SINGLE, x4 AS SINGLE, y4 AS SINGLE
DIM x5 AS SINGLE, y5 AS SINGLE, x6 AS SINGLE, y6 AS SINGLE
t2 = thick / 2
IF t2 < 1 THEN t2 = 1
a = _ATAN2(y2 - y1, x2 - x1)
x3 = x1 + t2 * COS(a + PD2)
y3 = y1 + t2 * SIN(a + PD2)
x4 = x1 + t2 * COS(a - PD2)
y4 = y1 + t2 * SIN(a - PD2)
x5 = x2 + t2 * COS(a + PD2)
y5 = y2 + t2 * SIN(a + PD2)
x6 = x2 + t2 * COS(a - PD2)
y6 = y2 + t2 * SIN(a - PD2)
ftri x6, y6, x4, y4, x3, y3, K
ftri x3, y3, x5, y5, x6, y6, K
END SUB
SUB ftri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG) ' ;fill triangle
DIM a&
a& = _NEWIMAGE(1, 1, 32)
_DEST a&
PSET (0, 0), K
_DEST 0
_MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
_FREEIMAGE a& '<<< this is important!
END SUB