Squares

General FreeBASIC programming questions.
Locked
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0144.bas

Code: Select all


dim as single c1 , c2
dim as single s1 , s2
dim as single x1 , x2
dim as single y1 , y2
dim as single deg1 , deg2
dim as single rad1
dim as single rad2

dim as integer xctr , yctr, divisions , fullcircle 
dim as integer radius1 , radius2

dim as integer xres , yres
'screen 19
screeninfo xres , yres
screenres xres , yres , 8 , 1 , 8

xctr = xres / 2
yctr = yres / 2

radius1 = 300
radius2 = 300

divisions = 45

rad1 = atn( 1 ) / divisions
rad2 = atn( 1 ) / ( divisions / 2 )
fullcircle = atn( 1 ) * 8 / rad1

   
        for deg1 = 0 to fullcircle step 4
            
            c1 = cos( deg1 * rad1 )
            s1 = sin( deg1 * rad1 )
   
            x1 = radius1 * c1 * c1 * c1
            y1 = radius1 * s1 * c1 * c1
            
        for deg2 = 0 to fullcircle step .1
           
            c2 = cos( deg2 * rad2 )
            s2 = sin( deg2 * rad2 )
       
            x2 = radius2 * c2 * c2 * c2 * atn( s2 )
            y2 = radius2 * s2
            
            pset( xctr +x1 +x2 , yctr +y1 +y2 ) , 9
            '
        next
   
    next

sleep
end

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0145.bas ( 7 Four Leaf Clovers )

Code: Select all


dim as single c1 , c2
dim as single s1 , s2
dim as single x1 , x2
dim as single y1 , y2
dim as single deg1 , deg2
dim as single rad1
dim as single rad2

dim as integer xctr , yctr, divisions , fullcircle 
dim as integer radius1 , radius2

dim as integer xres , yres
'screen 19
screeninfo xres , yres
screenres xres , yres , 8 , 1 , 8

xctr = xres / 2
yctr = yres / 2

radius1 = 500
radius2 = 200

divisions = 45

rad1 = atn( 1 ) / divisions
rad2 = atn( 1 ) / ( divisions / 2 )
fullcircle = atn( 1 ) * 8 / rad1

   
        for deg1 = 0 to fullcircle step 45
            
            c1 = cos( deg1 * rad1 )
            s1 = sin( deg1 * rad1 )
   
            x1 = radius1 * c1 * c1 * c1
            y1 = radius1 * s1 * c1 * c1
            
        for deg2 = 0 to fullcircle step .1
           
            c2 = cos( deg2 * rad2 )
            s2 = sin( deg2 * rad2 )
       
            x2 = radius2 * c2 * c2 * c2 * atn( s2 )
            y2 = radius2 * s2 * atn( c2 ) * atn( s2 )
            
            pset( xctr +x1 +x2 , yctr +y1 +y2 ) , 2
            '
        next
   
    next

sleep
end

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0146.bas

Code: Select all


dim as single c1 , c2
dim as single s1 , s2
dim as single x1 , x2
dim as single y1 , y2
dim as single deg1 , deg2
dim as single rad1
dim as single rad2

dim as integer xctr , yctr, divisions , fullcircle 
dim as integer radius1 , radius2

dim as integer xres , yres
'screen 19
screeninfo xres , yres
screenres xres , yres , 8 , 1 , 8

xctr = xres / 2
yctr = yres / 2

radius1 = 200
radius2 = 200

divisions = 45

rad1 = atn( 1 ) / divisions
rad2 = atn( 1 ) / ( divisions / 2 )
fullcircle = atn( 1 ) * 8 / rad1

   
        for deg1 = 0 to fullcircle step 1
            
            c1 = cos( deg1 * rad1 )
            s1 = sin( deg1 * rad1 )
   
            x1 = radius1 * c1 * c1 * c1 * atn( s1 ) * 6
            y1 = radius1 * s1 * atn( c1 ) * atn( s1 ) * 6
            
        for deg2 = 0 to fullcircle step .1
           
            c2 = cos( deg2 * rad2 )
            s2 = sin( deg2 * rad2 )
       
            x2 = radius2 * c2
            y2 = radius2 * s2 * atn( c2 ) * atn( s2 )
            
            pset( xctr +x1 +x2 , yctr +y1 +y2 ) , 9
            pset( xctr +x1 +x2 , yctr -y1 -y2 ) , 9
            
            pset( xctr -x1 -x2 , yctr +y1 +y2 ) , 9
            pset( xctr -x1 +x2 , yctr -y1 -y2 ) , 9
            '
        next
   
    next

sleep
end

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0147.bas

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

xctr = xres / 2
yctr = yres / 2

'radius = (xres*yres)/((xres+yres)*4)
radius = 250

divisions = 45

rad = atn( 1 ) / divisions

fullcircle = atn( 1 ) * 8 / rad

for deg1 = 0 to fullcircle step 45
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1=radius * c1 * atn( deg1 / 45 ) * c1 * c1 / s1
            y1=radius * s1 * atn( deg1 / 45 ) * s1 * s1 / c1
            
    for deg2 = 0 to fullcircle step .01

            c2 = cos( deg2 * rad * 8 )
            s2 =  sin( deg2 * rad * 8 )
   
            x2 = (radius*2) * c2 * c2 / 4
            y2 = (radius*2) * s2 * s2 / 4
            
            x3 = radius * c2 * atan2( y1 , x2 ) * atn( c2 * s2 )
            y3 = radius * s2 * atan2( x1 , y2 ) * atn( s2 * c2 )
            
        '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)

            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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0148.bas

Code: Select all

'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 = 250

divisions = 45

rad = atn( 1 ) / divisions

fullcircle = atn( 1 ) * 8 / rad

for deg1 = 0 to fullcircle step 45
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1=radius * c1 * atn( deg1 / 45 ) * c1 * c1 / s1
            y1=radius * s1 * atn( deg1 / 45 ) * s1 * s1 / c1
            
    for deg2 = 0 to fullcircle step .01

            c2 = cos( deg2 * rad * 8 )
            s2 =  sin( deg2 * rad * 8 )
   
            x2 = (radius*2) * c2 * c2 / 4 * atn( c2 * s2 )
            y2 = (radius*2) * s2 * s2 / 4 * atn( s2 * c2 )
            
            x3 = radius * c2 * atan2( y1 , x2 ) * atn( c2 * s2 )
            y3 = radius * s2 * atan2( x1 , y2 ) * atn( s2 * c2 )
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0149.bas

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 = 115

divisions = 45

rad = atn( 1 ) / divisions

fullcircle = atn( 1 ) * 8 / rad

for deg1 = 0 to fullcircle step 22.5
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1=radius * c1 * atn( deg1 / 45 ) * c1 * c1 / s1
            y1=radius * s1 * atn( deg1 / 45 ) * s1 * s1 / c1
            
    for deg2 = 0 to fullcircle step .01

            c2 = cos( deg2 * rad * 8 )
            s2 =  sin( deg2 * rad * 8 )
   
            x2 = (radius*2) * c2 * c2 / 3 * s2 * s1
            y2 = (radius*2) * s2 * s2 / 3 * c2 * c1
            
            x3 = radius * c2 * atan2( y1 , x2 ) / 3
            y3 = radius * s2 * atan2( x1 , y2 ) / 3
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0150.bas

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 step 22.5
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1=radius * c1 * atn( deg1 ) * c1 * c1 / s1
            y1=radius * s1 * atn( deg1 ) * s1 * s1 / c1
            
    for deg2 = 0 to fullcircle step .01

            c2 = cos( deg2 * rad * 8 )
            s2 =  sin( deg2 * rad * 8 )
   
            x2 = radius * c2 * c2 * c2
            y2 = radius * s2
            
            x3 = radius * c2 * atan2( y1 , x2 ) / 3
            y3 = radius * s2 * atan2( x1 , y2 ) / 3
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0151.bas

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 = 90

divisions = 45

rad = atn( 1 ) / divisions

fullcircle = atn( 1 ) * 8 / rad

for deg1 = 0 to fullcircle * 2 step 22.5
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1=radius * c1 * atn( deg1 ) * c1 * c1 / s1
            y1=radius * s1 * atn( deg1 ) * s1 * s1 / c1
            
    for deg2 = 0 to fullcircle step .01

            c2 = cos( deg2 * rad * 8 )
            s2 =  sin( deg2 * rad * 8 )
   
            x2 = radius * c2 * c2 * c2 / 2
            y2 = radius * s2 / 2
            
            x3 = radius * c2 * atan2( x2 , y2 ) / 2
            y3 = radius * s2 * atan2( y2 , x2 ) / 2
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0152.bas

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 = 90

divisions = 45

rad = atn( 1 ) / divisions

fullcircle = atn( 1 ) * 8 / rad

for deg1 = 0 to fullcircle * 4 step 22.5
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1=radius * c1 * atn( deg1 ) * c1 * c1 / s1
            y1=radius * s1 * atn( deg1 ) * s1 * s1 / c1
            
    for deg2 = 0 to fullcircle step .5

            c2 = cos( deg2 * rad )
            s2 =  sin( deg2 * rad )
            
            c3 = cos( deg2 * deg1 * rad * rad )
            s3 =  sin( deg2 * deg1 * rad * rad )
   
            x2 = radius * c2 * c2 / 2.5
            y2 = radius * s2 * s2 / 2.5
            
            x3 = radius * c3 * 1.01 * c3 * c3
            y3 = radius * s3 * 1.01 * s3 * s3
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0153.bas

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 = 90

divisions = 45

rad = atn( 1 ) / divisions

fullcircle = atn( 1 ) * 8 / rad

for deg1 = 0 to fullcircle * 4 step 22.5
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1=radius * c1 * atn( deg1 ) * c1 * c1 / s1
            y1=radius * s1 * atn( deg1 ) * s1 * s1 / c1
            
    for deg2 = 0 to fullcircle step .5

            c2 = cos( deg2 * rad )
            s2 =  sin( deg2 * rad )
            
            c3 = cos( deg2 * deg1 * rad * rad * c2 / 25 )
            s3 =  sin( deg2 * deg1 * rad * rad * s2 / 25 )
   
            x2 = radius * c2 * c2 / 2.5
            y2 = radius * s2 * s2 / 2.5
            
            x3 = radius * c3 * 1.01 * c3 * c3
            y3 = radius * s3 * 1.01 * s3 * s3
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0154.bas

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 = 90

divisions = 45

rad = atn( 1 ) / divisions

fullcircle = atn( 1 ) * 8 / rad

for deg1 = 0 to fullcircle * 4 step 11.25
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1 = radius * c1 * atn( deg1 ) * c1 * c1 / s1 / 3
            y1 = radius * s1 * atn( deg1 ) * s1 * s1 / c1 / 3
            
    for deg2 = 0 to fullcircle step 2

            c2 = cos( deg2 * rad )
            s2 =  sin( deg2 * rad )
            
            c3 = cos( deg2 * deg1 * rad * rad * c2 / 25 )
            s3 =  sin( deg2 * deg1 * rad * rad * s2 / 25 )
   
            x2 = radius * c2 * c2 / 2.5
            y2 = radius * s2 * s2 / 2.5
            
            x3 = radius * c3 * 1.01 * c3 * c3 * c2 * c2
            y3 = radius * s3 * 1.01 * s3 * s3 * s2 * s2
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0155.bas

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 step 22.5
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1 = radius * c1 * c1 * c1 / s1
            y1 = radius * s1 * s1 * s1 / c1
            
    for deg2 = 0 to fullcircle step .25

            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 * c2 * c2 * atan2( c1 , c2 * c3 )
            y2 = radius * s2 * atan2( s1 , s2 * s3 )
            
            x3 = radius * c3 * 1.01 * c3 * c3
            y3 = radius * s3 * 1.01 * s3 * s3
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0156.bas

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 45
    
            c1 = cos( deg1 * rad )
            s1 = sin( deg1 * rad )
   
            x1 = radius * c1 * c1 / c2
            y1 = radius * s1 * s1 / s2
            
    for deg2 = 0 to fullcircle step .1

            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 * c2 * c2 * c2 * atan2( c1 , c2 * c3 )
            y2 = radius * s2 * atan2( s1 , s2 * s3 )
            
            x3 = radius * c3 * 1.01 * c3 * c3
            y3 = radius * s3 * 1.01 * s3 * s3
            
        '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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0157.bas

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

albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

Here's Abstract_0158.bas

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 = 200

divisions = 45

rad = atn( 1 ) / divisions

fullcircle = atn( 1 ) * 8 / rad

for deg1 = 0 to fullcircle * 1 step 11.25
    
            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 , deg2 * c3 ) / 2
            y2 = radius * s2 * s3 * atan2( deg1 / deg2 , deg2 * s3 )
            
            x3 = radius * c3 * 1.01
            y3 = radius * s3 * 1.01
            
        '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

Locked