Code: Select all
'Colorizer by AndyA
'Abstract Doodle 0057
'https://www.freebasic.net/forum/viewtopic.php?f=3&t=16207&start=7065
'======================= Colorizing Code ===================================
Dim as Single band, coff, dist
Dim as ULong colr, idx, pal(48)
band = 3.0 'MUST be greater than 0.0 to avoid division by zero error
coff = 6.0 'palette array 'Color Index Offset' (0 to 47)
For idx = 0 To 47
Read pal(idx)
Next
Data &H0000FF,&H2000FF,&H4000FF,&H6000FF,&H8000FF,&HA000FF,&HC000FF,&HE000FF
Data &HFF00FF,&HFF00E0,&HFF00C0,&HFF00A0,&HFF0080,&HFF0060,&HFF0040,&HFF0020
Data &HFF0000,&HFF2000,&HFF4000,&HFF6000,&HFF8000,&HFFA000,&HFFC000,&HFFE000
Data &HFFFF00,&HE0FF00,&HC0FF00,&HA0FF00,&H80FF00,&H60FF00,&H40FF00,&H20FF00
Data &H00FF00,&H00FF20,&H00FF40,&H00FF60,&H00FF80,&H00FFA0,&H00FFC0,&H00FFE0
Data &H00FFFF,&H00E0FF,&H00C0FF,&H00A0FF,&H0080FF,&H0060FF,&H0040FF,&H0020FF
'===========================================================================
dim as single c1 , c2 , c3
dim as single s1 , s2 , s3
dim as single x1 , x2 , x3
dim as single y1 , y2 , y3
dim as single deg1 , deg2 , deg3
dim as single rad
dim as integer xctr , yctr , radius , divisions , fullcircle
dim as integer xres , yres
screeninfo xres , yres
screenres xres , yres , 32 , 1 , 8
xctr = xres / 2
yctr = yres / 2
'radius = (xres*yres)/((xres+yres)*4)
radius = 100
divisions = 45
rad = atn( 1 ) / divisions
fullcircle = atn( 1 ) * 8 / rad
for deg1 = 0 to fullcircle * 2 step 720
c1 = cos( deg1 * rad )
s1 = sin( deg1 * rad )
x1 = radius * c1 * c1 / c2
y1 = radius * s1 * s1 / s2
for deg2 = 0 to fullcircle step .01
c2 = cos( deg2 * rad )
s2 = sin( deg2 * rad )
c3 = cos( deg2 * deg1 * rad * rad * c2 / 10 )
s3 = sin( deg2 * deg1 * rad * rad * s2 / 10 )
x2 = radius * c2 * c3 * atan2( deg1 , deg2 ) * 2
y2 = radius * s2 * s3 * atan2( deg1 , deg2 )
x3 = radius * c3 * 1.01 * atan2( c2 , c1 ) * 2
y3 = radius * s3 * 1.01 * atan2( s2 , s1 )
'Calc distance from current x1, y1 to the center of the screen
'then apply MOD of 48 to get a valid palette index value
dist = Sqr((xctr-x1)*(xctr-x1) + (yctr-y1)*(yctr-y1))
colr = pal((Int(dist/band) + coff) Mod 48)
'colr = &H8000FF
pset( xctr +x1 +x2 +x3 , yctr +y1 +y2 +y3 ) , colr
pset( xctr +x1 +x2 +x3 , yctr -y1 -y2 -y3 ) , colr
pset( xctr -x1 -x2 -x3 , yctr +y1 +y2 +y3 ) , colr
pset( xctr -x1 -x2 -x3 , yctr -y1 -y2 -y3 ) , colr
next
next
Sleep
end