Post by tsh73 on Apr 14, 2018 5:18:04 GMT -5
Just a way to do it. Probably one of a many
'Rotating color
'tsh73, April 2018
nomainwin
desiredWidth = 600
desiredHeight = 600
gosub [ajustWindow]
UpperLeftX = (DisplayWidth - WindowWidth)/2
UpperLeftY = (DisplayHeight - WindowHeight)/2
open "Colorful spirals" for graphics_nsb_nf as #gr
#gr "trapclose [quit]"
#gr "down"
#gr "fill darkgreen; flush"
#gr "home; posxy cx cy"
r=5
RR=0.85*cx
pi=acs(-1)
for i=r to RR step 2*r
l=2*pi*i
n=l/(2*r)
for a=0 to 2*pi step 2*pi/n
'c=i/RR/2 '0..1 red to red, 0..0.5 first half - light colors, up to cyan
'c=i/RR+a/(2*pi) 'single spiral
'c=i/RR+a/(2*pi)*2 'more
c=i/RR+a/(2*pi)*3 'MORE!!!
#gr "color ";rainbow$(c)
#gr "backcolor ";rainbow$(c)
x=cx+i*cos(a)
y=cy+i*sin(a)
#gr "place ";x;" ";y
#gr "circlefilled ";r
next
next
#gr "flush"
wait
[quit]
timer 0
close #gr
end
'---------------------------------------------
' 0..1 into red-green-blue-red continuous colors
function rainbow$(x)
hi = int((x*6) mod 6)+ 5*(x<0) 'fixed to 0..5
f = (x*6) mod 1 + (x<0) 'frac, 0..1
q = (1-f)
select case hi
case 0
r = 1: g = f: b = 0
case 1
r = q: g = 1: b = 0
case 2
r = 0: g = 1: b = f
case 3
r = 0: g = q: b = 1
case 4
r = f: g = 0: b = 1
case 5
r = 1: g = 0: b = q
end select
R = int(r*255)
G = int(g*255)
B = int(b*255)
rainbow$= R;" ";G;" ";B
end function
'-------------------------------------------------
[ajustWindow]
UpperLeftX = 20
UpperLeftY = 20
WindowWidth = 200 '100 seems to be too much - works different
WindowHeight = 100
open "Ajusting..." for graphics_nsb_nf as #gr
#gr, "home ; down ; posxy x y"
'x, y give us width, height
width = 2*x : height = 2*y
close #gr
slackX = 200-width
slackY = 100-height
WindowWidth = desiredWidth + slackX
WindowHeight = desiredHeight + slackY
return
/code]